Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_request.c @ 8238:a3257a725b3d quic
Fixed header creation for header_only responses in HTTP/3.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 19 Mar 2020 15:03:09 +0300 |
parents | 1e45c02f6376 |
children | 69365c7bb07f |
comparison
equal
deleted
inserted
replaced
8237:ff540f13d95d | 8238:a3257a725b3d |
---|---|
257 c = r->connection; | 257 c = r->connection; |
258 | 258 |
259 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 create header"); | 259 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 create header"); |
260 | 260 |
261 /* XXX support chunked body in the chunked filter */ | 261 /* XXX support chunked body in the chunked filter */ |
262 if (r->headers_out.content_length_n == -1) { | 262 if (!r->header_only && r->headers_out.content_length_n == -1) { |
263 return NULL; | 263 return NULL; |
264 } | 264 } |
265 | 265 |
266 len = 0; | 266 len = 0; |
267 | 267 |
308 | 308 |
309 len += ngx_http_v3_encode_prefix_int(NULL, 53, 4) | 309 len += ngx_http_v3_encode_prefix_int(NULL, 53, 4) |
310 + ngx_http_v3_encode_prefix_int(NULL, n, 7) + n; | 310 + ngx_http_v3_encode_prefix_int(NULL, n, 7) + n; |
311 } | 311 } |
312 | 312 |
313 if (r->headers_out.content_length_n == 0) { | 313 if (r->headers_out.content_length_n > 0) { |
314 len += ngx_http_v3_encode_prefix_int(NULL, 4, 4) + 1 + NGX_OFF_T_LEN; | |
315 | |
316 } else if (r->headers_out.content_length_n == 0) { | |
314 len += ngx_http_v3_encode_prefix_int(NULL, 4, 6); | 317 len += ngx_http_v3_encode_prefix_int(NULL, 4, 6); |
315 | |
316 } else { | |
317 len += ngx_http_v3_encode_prefix_int(NULL, 4, 4) + 1 + NGX_OFF_T_LEN; | |
318 } | 318 } |
319 | 319 |
320 if (r->headers_out.last_modified == NULL | 320 if (r->headers_out.last_modified == NULL |
321 && r->headers_out.last_modified_time != -1) | 321 && r->headers_out.last_modified_time != -1) |
322 { | 322 { |
452 r->headers_out.content_type.len = b->last - p; | 452 r->headers_out.content_type.len = b->last - p; |
453 r->headers_out.content_type.data = p; | 453 r->headers_out.content_type.data = p; |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 if (r->headers_out.content_length_n == 0) { | 457 if (r->headers_out.content_length_n > 0) { |
458 /* content-length: 0 */ | |
459 *b->last = 0xc0; | |
460 b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 6); | |
461 | |
462 } else if (r->headers_out.content_length_n > 0) { | |
463 /* content-length: 0 */ | 458 /* content-length: 0 */ |
464 *b->last = 0x70; | 459 *b->last = 0x70; |
465 b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 4); | 460 b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 4); |
466 p = b->last++; | 461 p = b->last++; |
467 b->last = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n); | 462 b->last = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n); |
468 *p = b->last - p - 1; | 463 *p = b->last - p - 1; |
464 | |
465 } else if (r->headers_out.content_length_n == 0) { | |
466 /* content-length: 0 */ | |
467 *b->last = 0xc0; | |
468 b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 6); | |
469 } | 469 } |
470 | 470 |
471 if (r->headers_out.last_modified == NULL | 471 if (r->headers_out.last_modified == NULL |
472 && r->headers_out.last_modified_time != -1) | 472 && r->headers_out.last_modified_time != -1) |
473 { | 473 { |
519 header[i].value.len, | 519 header[i].value.len, |
520 7); | 520 7); |
521 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); | 521 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); |
522 } | 522 } |
523 | 523 |
524 if (r->header_only) { | |
525 b->last_buf = 1; | |
526 } | |
527 | |
524 cl = ngx_alloc_chain_link(c->pool); | 528 cl = ngx_alloc_chain_link(c->pool); |
525 if (cl == NULL) { | 529 if (cl == NULL) { |
526 return NULL; | 530 return NULL; |
527 } | 531 } |
528 | 532 |