diff options
| author | Sergey Kandaurov <pluknet@nginx.com> | 2021-09-13 16:25:23 +0300 |
|---|---|---|
| committer | Sergey Kandaurov <pluknet@nginx.com> | 2021-09-13 16:25:23 +0300 |
| commit | ee5d9279288beec74e563c5fd3e1d8dd0171fb70 (patch) | |
| tree | 852d6062b454ba914f03d82f4fbc448a9894dc03 | |
| parent | 0ac1f6fd47b59bd59abb4c8465e622e60f666ee0 (diff) | |
| download | nginx-ee5d9279288beec74e563c5fd3e1d8dd0171fb70.tar.gz nginx-ee5d9279288beec74e563c5fd3e1d8dd0171fb70.tar.bz2 | |
HTTP/3: Huffman encoding for the Content-Type response field.
| -rw-r--r-- | src/http/v3/ngx_http_v3_filter_module.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/http/v3/ngx_http_v3_filter_module.c b/src/http/v3/ngx_http_v3_filter_module.c index 71aa839e1..45063524b 100644 --- a/src/http/v3/ngx_http_v3_filter_module.c +++ b/src/http/v3/ngx_http_v3_filter_module.c @@ -359,35 +359,35 @@ ngx_http_v3_header_filter(ngx_http_request_t *r) } if (r->headers_out.content_type.len) { - n = r->headers_out.content_type.len; - if (r->headers_out.content_type_len == r->headers_out.content_type.len && r->headers_out.charset.len) { - n += sizeof("; charset=") - 1 + r->headers_out.charset.len; - } + n = r->headers_out.content_type.len + sizeof("; charset=") - 1 + + r->headers_out.charset.len; - b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, - NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, - NULL, n); + p = ngx_pnalloc(r->pool, n); + if (p == NULL) { + return NGX_ERROR; + } - p = b->last; - b->last = ngx_cpymem(b->last, r->headers_out.content_type.data, - r->headers_out.content_type.len); + p = ngx_cpymem(p, r->headers_out.content_type.data, + r->headers_out.content_type.len); - if (r->headers_out.content_type_len == r->headers_out.content_type.len - && r->headers_out.charset.len) - { - b->last = ngx_cpymem(b->last, "; charset=", - sizeof("; charset=") - 1); - b->last = ngx_cpymem(b->last, r->headers_out.charset.data, - r->headers_out.charset.len); + p = ngx_cpymem(p, "; charset=", sizeof("; charset=") - 1); - /* update r->headers_out.content_type for possible logging */ + p = ngx_cpymem(p, r->headers_out.charset.data, + r->headers_out.charset.len); - r->headers_out.content_type.len = b->last - p; - r->headers_out.content_type.data = p; + /* updated r->headers_out.content_type is also needed for logging */ + + r->headers_out.content_type.len = n; + r->headers_out.content_type.data = p - n; } + + b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, + NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, + r->headers_out.content_type.data, + r->headers_out.content_type.len); } if (r->headers_out.content_length == NULL) { |
