diff options
author | Piotr Sikora <piotrsikora@google.com> | 2017-03-24 03:37:34 -0700 |
---|---|---|
committer | Piotr Sikora <piotrsikora@google.com> | 2017-03-24 03:37:34 -0700 |
commit | cfdce50657cb8d25058de3d677f03cdef0d5de51 (patch) | |
tree | 122dd12203f4dcf5a6c2438fe13f31af8d8bce82 /src/http/ngx_http_core_module.c | |
parent | fa0992ed295ba83f711ca3d1ba8fc1baaa5760ca (diff) | |
download | nginx-cfdce50657cb8d25058de3d677f03cdef0d5de51.tar.gz nginx-cfdce50657cb8d25058de3d677f03cdef0d5de51.zip |
Added support for trailers in HTTP responses.
Example:
ngx_table_elt_t *h;
h = ngx_list_push(&r->headers_out.trailers);
if (h == NULL) {
return NGX_ERROR;
}
ngx_str_set(&h->key, "Fun");
ngx_str_set(&h->value, "with trailers");
h->hash = ngx_hash_key_lc(h->key.data, h->key.len);
The code above adds "Fun: with trailers" trailer to the response.
Modules that want to emit trailers must set r->expect_trailers = 1
in header filter, otherwise they might not be emitted for HTTP/1.1
responses that aren't already chunked.
This change also adds $sent_trailer_* variables.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r-- | src/http/ngx_http_core_module.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index b5be1ffeb..02059efd8 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -2485,6 +2485,13 @@ ngx_http_subrequest(ngx_http_request_t *r, return NGX_ERROR; } + if (ngx_list_init(&sr->headers_out.trailers, r->pool, 4, + sizeof(ngx_table_elt_t)) + != NGX_OK) + { + return NGX_ERROR; + } + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); sr->main_conf = cscf->ctx->main_conf; sr->srv_conf = cscf->ctx->srv_conf; |