[PATCH 1 of 3] HTTP: add support for trailers in HTTP responses

Piotr Sikora piotrsikora at google.com
Fri Jun 2 09:05:47 UTC 2017

Hey Maxim,

> In your patch, you test r->expect_trailers in two places in
> chunked filter:
> 1. when you decide whether to use chunked encoding or not, in
>    ngx_http_chunked_header_filter();
> 2. when you generate trailer, in ngx_http_chunked_body_filter().
> I mostly agree with (1) (I would like see it configurable too, but
> it's probably up to a module which adds trailers to decide, so
> don't belong to this particular patch), but don't see any reasons
> for (2).

This is done to avoid unexpected behavior when r->expect_trailers
isn't set, i.e. if module added trailers, but didn't set
r->expect_trailers, then without (2) trailers would be emitted only if
Content-Encoding was already chunked, but not otherwise.

Testing r->expect_trailers in both (1) and (2) ensures that Trailers
are emitted in consistent manner, without depending on unrelated
factors, like gzip support by the client, etc.

> Certainly merging is a bad idea either.  May be the solution would
> be avoid sending trailers for header-only requests consistently
> for both HTTP/1.1 and HTTP/2.

Done, I removed trailers from headers-only HTTP/2 responses.

As mentioned earlier, I also removed "TE: trailers" requirement and
merged whole trailer-part into one buffer, in case of trailers.

Best regards,
Piotr Sikora

More information about the nginx-devel mailing list