aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2020-03-19 15:03:09 +0300
committerRoman Arutyunyan <arut@nginx.com>2020-03-19 15:03:09 +0300
commit8ad2707d4f5c007ec308262ea03481d95eee7e02 (patch)
tree2f558664ef8f2f9f9758906bb80e901231f17979 /src/http/v3/ngx_http_v3_request.c
parent31e794f0ad881248f72e87f32e6e594cb222e94d (diff)
downloadnginx-8ad2707d4f5c007ec308262ea03481d95eee7e02.tar.gz
nginx-8ad2707d4f5c007ec308262ea03481d95eee7e02.zip
Fixed header creation for header_only responses in HTTP/3.
Diffstat (limited to 'src/http/v3/ngx_http_v3_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index 75488db1d..9a2654fd4 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -259,7 +259,7 @@ ngx_http_v3_create_header(ngx_http_request_t *r)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 create header");
/* XXX support chunked body in the chunked filter */
- if (r->headers_out.content_length_n == -1) {
+ if (!r->header_only && r->headers_out.content_length_n == -1) {
return NULL;
}
@@ -310,11 +310,11 @@ ngx_http_v3_create_header(ngx_http_request_t *r)
+ ngx_http_v3_encode_prefix_int(NULL, n, 7) + n;
}
- if (r->headers_out.content_length_n == 0) {
- len += ngx_http_v3_encode_prefix_int(NULL, 4, 6);
-
- } else {
+ if (r->headers_out.content_length_n > 0) {
len += ngx_http_v3_encode_prefix_int(NULL, 4, 4) + 1 + NGX_OFF_T_LEN;
+
+ } else if (r->headers_out.content_length_n == 0) {
+ len += ngx_http_v3_encode_prefix_int(NULL, 4, 6);
}
if (r->headers_out.last_modified == NULL
@@ -454,18 +454,18 @@ ngx_http_v3_create_header(ngx_http_request_t *r)
}
}
- if (r->headers_out.content_length_n == 0) {
- /* content-length: 0 */
- *b->last = 0xc0;
- b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 6);
-
- } else if (r->headers_out.content_length_n > 0) {
+ if (r->headers_out.content_length_n > 0) {
/* content-length: 0 */
*b->last = 0x70;
b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 4);
p = b->last++;
b->last = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n);
*p = b->last - p - 1;
+
+ } else if (r->headers_out.content_length_n == 0) {
+ /* content-length: 0 */
+ *b->last = 0xc0;
+ b->last = (u_char *) ngx_http_v3_encode_prefix_int(b->last, 4, 6);
}
if (r->headers_out.last_modified == NULL
@@ -521,6 +521,10 @@ ngx_http_v3_create_header(ngx_http_request_t *r)
b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len);
}
+ if (r->header_only) {
+ b->last_buf = 1;
+ }
+
cl = ngx_alloc_chain_link(c->pool);
if (cl == NULL) {
return NULL;