-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TE: trailers #18
Comments
See also #16. |
Also, the current definition is:
That doesn't account for H2 (which doesn't use chunked encoding). |
except it sort of does account for h2 because 7540 specifically calls out
the "chunked trailer part" of 7230 section 4.1.2 even while saying it does
not use chunked encodings. (8.1 of 7540)... and H2 can send TE: trailers.
with all that being said, this is a silly thing to negotiate.
…On Wed, Feb 7, 2018 at 8:04 PM, Mark Nottingham ***@***.***> wrote:
Also, the current definition is:
The presence of the keyword "trailers" indicates that the client is
willing to accept trailer fields in a chunked transfer coding, as defined
in Section 4.1.2, on behalf of itself and any downstream clients.
That doesn't account for H2 (which doesn't use chunked encoding).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAP5s3vpKESkwE516NDNq2jD0gOH6G_tks5tSkgogaJpZM4JYB5a>
.
|
Oh sure - just wanted to leave a note so that when we have an opportunity to make it a bit clearer we don't forget. |
So, the only case that
Does anyone know of:
? |
So does this in combination with
mean that an intermediary is supposed to reject the connection if it doesn't support Can an intermediary that supports trailers forward the request without |
To your first question, no; intermediaries have three options regarding trailers:
|
The situation I've identified is the following : an H1 client makes a request to a gateway with TE: trailers. The gateway forwards the request to an H2 server. Trailers are standard in H2 and you can only detect them once you get your second series of HEADERS+CONTINUATION frames after the first end-of-headers flag. But in H1 it's only possible to have trailers after content-length. So here the intermediary would need to chunk-encode the response to be able to optionally append the trailers if the client wants them. Since most of the time trailers are not needed, using TE:trailers as a hint to switch to chunked-encoding is the only suitable option in my opinion. |
Hey Willy - H2 supports the I'm not sure what you mean by "in H1 it's only possible to have trailers after content-length" - In H1, |
For the Trailers header field, it's only a SHOULD so I never considered it a reliable enough signal. Should I ? If so I agree that it's much easier to decide to switch the H1 response to chunked-encoding whenever a Trailers header field is present! For the other one, I'd claim -ENOCOFFEE! Of course I meant "not possible". What I mean was that the H2 transport always supports trailers while the H1 transport doesn't always permit it. |
If you think it's safe to silently discard trailers whenever the Trailer header field is absent, for both H1 and H2, that could indeed significantly simplify the approach for me. In this case I'd suggest that we update the wording around the Trailer header field description to explicitly mention that intermediaries are very likely to discard fields not announced there. |
I would generally hope intermediaries use chunked encoding when I would also generally expect servers sending trailers to omit Content-Length, as that is not permitted in HTTP/1.1. RFC7230 §3.3.2 "A sender MUST NOT send a Content-Length header field in any message that contains a Transfer-Encoding header field." So as proxy, I would just use Content-Length if it is present, and otherwise use chunked encoding. If I receive a response over HTTP/2 that contains Content-Length and also later contains trailers, then I would drop the trailers on the floor because that is permitted and the only other real alternatives are to fully buffer or to generate an error. (Note: for this discussion I am ignoring the cases where there is no response body, like HEAD, since they complicate matters without furthering the conversation.) I'd only expect advanced use cases to base decisions off the To get back to the original issue, a server can use So I agree with #18 (comment), but I would just add that I would generally expect intermediaries to omit |
The case you mention regarding H2 response containing content-length forwarded to H1 client is the one I'm interested in better covering (sorry if my description was not clear). With H2 you discover trailers only in the framing, though @mnot suggests that I should trust the Trailer header field accompanying the message. There is one good point about trusting this one which is that it is agnostic to the direction. And indeed, even h2spec tests trailers support on the request path using a POST and a Trailers header field, so this makes sense. I would suspect that a properly behaving server would not emit a Trailers header field if the request does not contain TE. In this regard it starts to make sense for an intermediary to rely exclusively on Trailers alone. |
In HTTP/1.1 you discover trailers only in the framing as well (at least to the same degree as in HTTP/2), it's just that most transport encoding types didn't support trailers in HTTP/1.1. For the most part "HTTP/2 semantics" don't really exist; HTTP/2 is mostly just a transport and HTTP/1.1 downgrade from HTTP/2 is a common thing for proxies. Thus I don't see any reason to change anything in HTTP/2, so simply don't support Content-Length+trailers when doing HTTP/1.1 downgrade since that has never worked. A properly behaving server can emit Trailers even without TE: trailers, but it basically is okay with them getting thrown away (this is part of §4.1.2 quoted above). The presence of the Trailer header is a SHOULD, so it is not guaranteed and valid implementations may not include it. To contrast, the absence of Content-Length when there are trailers in HTTP/1.1 is a MUST (§3.3.2 for sending and again in §3.3.3 for receiving). If downgrading an HTTP/2 response to HTTP/1.1 and it contains both Content-Length and trailers, then there is no way to maintain full fidelity; you either have to drop the Content-Length or the trailers. HTTP/2 implementations have to be aware of that if they care about HTTP/1.1 downgrade. Relying on Content-Length works in both directions as well, so I don't understand the eagerness to use Trailer. |
The point is that in H1 the presence of content-length (or more precisely the absence of chunked) implies there will be no trailers. In H2 you can have a content-length even when using trailers since content-length is not used for the transport itself. For sure it's trivial to discard them. My goal is to avoid discarding them whenever there is a hint indicating they might be present, and this requires switching from content-length to chunked encoding when translating H2 to H1. At first I only wanted to do this when there's no content-length in the H2 response but this is a very weak signal since C-L can be present even with trailers. If instead I consider that whenever a server advertises "Trailer:" in H2 I automatically have to switch to chunked encoding, it's better because the only lost trailers will be those sent by a server not advertising them upfront while using content-length. This possibly is the best match we can have between the possibilities of each side while staying 100% compliant with the spec. |
A more basic question in relation to this. Chunked Transfer Encoding is a mandatory feature of HTTP/1.1 but client support for trailing headers is optional. Therefore, the client uses the In HTTP/2 and HTTP/3 the concept of Chunked Transfer Encoding is effectively built in to the binary transport and my reading of the specifications is that clients are expected to support a single trailing Should This difference with HTTP/1.1 presents a challenge when attempting to write a generic specification of HTTP message syntax (e.g. the HTTPter proposal). Maybe |
Personally, I think of In #219 for Semantics, I de-emphasized the role of TE because I don't think it applies in general across HTTP versions. The definition is still there, but we don't require a client to preserve trailer fields if it has sent |
Meanwhile, we've decided to prohibit folks from automatically "upgrading" trailers into headers, unless a definition specifically allows it (and I don't think there's a strong expectation that intermediaries will keep themselves aware of that. Given that, this is an even weaker signal; its absence tells a server that trailers might be dropped by some hop along the way -- but then again, they might not. The only benefits the server gets are:
I'll do a PR to clarify along these lines. Personally, I'd also be willing to discuss deprecating |
... or, as mentioned in the PR, make it a separate header. |
Deprecating My (I assume a little naive) reading of the relevant docs seems to imply that It's not clear to me that a well-formed implementation of HTTP can skip the Whether that's an oversight, by desigh/choice or something else, as an implementor of HTTP client and server, I would say it's less than clear what the exact semantics should be. |
The use case for
TE: trailers
is described in RFC7230, section 4.1.2:Section 4.3 adds to that:
A few observations:
TE: trailers
would be helpful. E.g., should a User-Agent include it on all connections that support trailers? Should an intermediary include it on all connections when the upstream connection also supports trailers, or it commits to buffering the response?TE: trailers
can't infer much from it; it only knows that trailers are going to be processed by the path, but could still be dropped on the floor by the client (in 4.1.2: "recipient MAY process the fields"). Is it really a useful signal?The text was updated successfully, but these errors were encountered: