Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora
August 31, 2016 09:32PM
Hey Maxim,

> Could you please describe one of the uses cases in details?
> That's what I'm asking all the time, and still didn't get even a
> single description of a real-world use case.

You were definitely given some real-world use cases in this thread already:

http://mailman.nginx.org/pipermail/nginx-devel/2016-June/008441.html
http://mailman.nginx.org/pipermail/nginx-devel/2016-July/008586.html
http://mailman.nginx.org/pipermail/nginx-devel/2016-August/008619.html

But fine, I can repeat a few of those:

1. Checksums: web server or proxy sends "Content-SHA256:
$response_body_sha256" back to the client. Since it doesn't know the
checksum ahead of time (either because it's a streaming proxy or
because it's not feasible to read the whole file twice), it must sent
it in the trailers. Thanks to the Fetch API, JavaScript clients in the
browser can verify that the checksum matches what was received.

2. Logging: in distributed systems, it's not always feasible or even
possible to write logs at each server that was involved in generating
response, so backend servers can pass information to log (processing
time, profiling data, etc.) in the trailers, so that everything can be
aggregated and/or logged in one place, usually by the front-end proxy.

3. Trailing status (Microservices): servers send "Status: OK" in the
trailers after successfully completing request. This is needed,
because a lot of things can go wrong between sending "200 OK" status
code in the headers and completing response.

Is that enough?

> The same applies to HTTP/1.1. Yet trailers are (mostly?) unused
> for many years. Moreover, it is clearly understood now that
> merging trailer headers to headers as supposed by HTTP/1.1 is a
> security disaster.

As stated previously, I have no intention of merging them together.

> Merging trailers with headers can happen somewhere else as long as
> you pass trailers through. And it will be perfectly in line with
> HTTP/1.1 specs.

Yes, but then it's not NGINX's problem, is it?

> The only potentially bad thing that can happen without forcing
> chunked transfer encoding is that trailers configured won't be
> sent if Content-Length is know. If this is critical for a use
> case, the Content-Length can be explicitly removed with additional
> configuration.

If you already configured NGINX to send and/or pass trailers, then why
would you also need to configure NGINX to send and/or pass trailer
even if Content-Length is present? This doesn't make any sense.

Furthermore, even with such simple configuration:

location / {
add_trailer "Content-SHA256" "$request_body_sha256";
root /var/www;
gzip on;
}

clients that support gzip would receive Content-SHA256 trailer, while
those that didn't request gzip would not. Again, this doesn't make any
sense.

> Additionally, this is not something expected to happen when
> proxying, as Content-Length won't be known anyway if there are
> trailers in the upstream response.

That's only assuming HTTP/1.1. There might be other upstream protocols
that produce trailers or trailer-like metadata.

> On the other hand, forcing chunked transfer encoding based on "TE:
> trailers" looks all the way wrong:
>
> - it will change the behaviour of nginx for such clients, even if
> there are no other reasons to do so;

Like I previously said, I'm happy to add r->expect_trailers, so that
modules that want to emit trailers could signal that, in which case
chunked encoding would be forced only when trailers are expected to
appear.

> - it won't change the behaviour for other HTTP/1.1 clients who
> actually support trailers but doesn't advertize it via "TE:
> trailers", and thus trailers will be lost in some cases anyway.

Again, I'm fine dropping this requirement...

> Gzip is something you explicitly enable in the configuration to
> change the content of some responses. It changes the content, and
> this in turn results in chunked transfer encoding when using
> HTTP/1.1.

You need to explicitly add and/or enable passing of trailers as well.

> In contrast, trailers is something exists only in case of chunked
> transfer encoding. Depending on the use case, it may make sense
> to either:
>
> 1. once trailers are configured, force chunked encoding and sent
> trailers (if it is possible to do so); or

Isn't that what I'm proposing?

> 2. once trailers are configured, sent them as long as chunked
> encoding is used.
>
> Obviously enough, second approach is more flexible. And, as long
> as there is a way to force chunked encoding by other means, allows
> to do exactly the same thing as the first one, plus some additional
> things.

I honestly don't see what value would this add, other than confusing
people as to why trailers sometimes work and sometimes don't.

Best regards,
Piotr Sikora

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

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

Piotr Sikora 918 June 26, 2016 07:14PM

[PATCH 2 of 2] Headers filter: add "add_trailer" directive

Piotr Sikora 421 June 26, 2016 07:14PM

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

Maxim Dounin 376 June 27, 2016 09:46AM

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

Piotr Sikora 385 June 27, 2016 10:38AM

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

shuxinyang 453 June 27, 2016 01:06PM

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

Piotr Sikora 360 June 27, 2016 01:14PM

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

shuxinyang 379 June 27, 2016 02:56PM

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

Piotr Sikora 474 June 27, 2016 03:16PM

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

shuxinyang 388 June 27, 2016 06:04PM

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

Piotr Sikora 355 June 27, 2016 07:18PM

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

shuxinyang 359 June 27, 2016 09:00PM

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

Piotr Sikora 324 June 27, 2016 09:46PM

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

Maxim Dounin 363 June 27, 2016 01:54PM

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

Piotr Sikora 363 June 27, 2016 03:06PM

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

Piotr Sikora 332 June 30, 2016 03:58PM

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

Maxim Dounin 371 July 04, 2016 10:22AM

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

Piotr Sikora 366 July 06, 2016 05:04PM

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

Maxim Dounin 352 July 07, 2016 11:02AM

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

Piotr Sikora 332 July 07, 2016 04:10PM

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

Maxim Dounin 340 July 07, 2016 07:22PM

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

Piotr Sikora 390 July 13, 2016 01:28PM

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

Maxim Dounin 403 July 13, 2016 02:44PM

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

Piotr Sikora 312 July 13, 2016 08:36PM

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

Alexey Ivanov 335 July 20, 2016 06:36PM

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

Maxim Dounin 316 July 20, 2016 09:24PM

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

Alexey Ivanov 345 July 20, 2016 09:34PM

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

Maxim Dounin 417 July 21, 2016 09:46AM

[PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora 322 August 01, 2016 01:00AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora 307 August 01, 2016 03:36AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Maxim Dounin 281 August 01, 2016 09:24AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora 440 August 01, 2016 01:58PM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Maxim Dounin 339 August 03, 2016 10:26PM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora 295 August 18, 2016 09:14PM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Valentin V. Bartenev 290 August 19, 2016 07:16AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Maxim Dounin 291 August 23, 2016 11:00AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Maxim Dounin 506 August 23, 2016 10:24AM

Re: [PATCH] HTTP: add support for trailers in HTTP responses

Piotr Sikora 953 August 31, 2016 09:32PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready