You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A client MUST be prepared to accept one or more 1xx status responses prior to a regular response...
I have two questions around this:
What is the intended Envoy behavior? Should we proxy these or drop any 1xx beyond the first?
If we do want to proxy, I think what we need to do is fix HTTP/2 codec_impl.cc to handle multiple informational headers (currently just one, see waiting_for_non_informational_headers_ logic) and then instead of using booleans for has_continue_headers_ and continued_headers_continued_, we can use integers to count the number that we have received and forwarded in HCM. Does this make sense?
The more I look at the spec, I'm becoming convinced that while multiple 1xx should be supported, i.e. different 1xx informational responses, but multiple 100 doesn't make any sense. It's not stated explicitly, but this seems to be a reasonable interpretation.
Based on the RFC 7231 description "A client MUST be able to parse one or more 1xx responses received prior to a final response, even if the client does not expect one. A user agent MAY ignore unexpected 1xx responses." I'm going to go with "allow multiple 100 continues but ignore proxying all but the first.". I think this is the intended behavior today but the integration test in my PR seems to show that we need to do some work to avoid header/trailers confusion in this case.
We should fix brokenness while attempting to proxy multiple 1xx response headers. The first step could be a simpler change to fail if multiple 1xx responses are detected. I don't know how common multiple 1xx responses are; I can see a server replying with 100 followed by 103 or 102. I don't know how common 102 or 103 responses are: 103 is from an RFC published in 2017, 102 is part of webdav
I think the spec suggests that the fix could be just ignoring unexpected headers. If we don't support 102, for example, then it's acceptable to ignore it, rather than fail. It would be good to clarify if failure semantics are preferred to ignoring semantics.
FWIW I suggest we keep it simple and (correctly) ignore all 1xx responses after the first. I think this was @alyssawilk's intention and I would just do this until someone complains about it.
I have taken another shot at this in #12037. The idea now is to really ignore any 1xx that follow the initial 1xx. While working on tests, the treatment of non-100 1xx headers came up, and it seems it's a bit weird. Consider the following sequences of headers:
[100, 102] - this is simple, we invoke decode100ContinueHeaders() and then terminates on the 102 as we have multiple 1xx.
[100, 200] - also simple, we invoke decode100ContinueHeaders() and then decodeHeaders().
[102, 200] - this seems weird, I think we will invoke decodeHeaders() twice.
I'm thinking it would be good to be more strict and/or clarify what happens to non-100 1xx. The following options seems possible:
Non-100 1xx are always ignored. Since these are only informational, it seems possible to ignore some 1xx, will we break any users?
Always forward 1xx, via decodeHeaders(). I think we do this today, but I didn't see a test.
Introduce some special purpose decode handler for these non-100 1xx.
I think that (2) is a bit confusing, since almost always, for HTTP/1 and HTTP/2, we're seeing a single decodeHeaders() in filters etc, but we have this corner edge case, which it's likely most folks won't anticipate.
Only 102 Processing and 103 Early Hints are informational and could be potentially discarded, but there is no reason why they should be, to be honest.
100 Continue is critical and would break request flow if not forwarded downstream, though multiple 100 Continue could be collapsed into a single one (i.e. the first one would be forwarded, and subsequent 100 Continue would be ignored), but that's really the only case where we could ignore 1xx response.
101 Switching Protocols is hop-by-hop, so I guess it doesn't matter too much here.
The code as written was just to forward literal 100s followed by informational header, or 101 followed by upgrade.
101 is "special" insofar as there shouldn't be response headers after, so treating that like normal headers since they're the only response headers (and important) kind of makes sense to me.
Easiest would be to just drop other 1xx headers and document we don't support them. Less easy would be to support multiple other 1xx headers by some mechanism or other. I'm pretty neutral about that - 100-continue is needed for a bunch of things to work properly but I don't know of anyone who really requires 102 or 103.
Based on what @alyssawilk and @PiotrSikora say, I'm going to go with drop, test and document this behavior. I'm pretty worried about having a decodeHeaders() double invocation corner case, since not all filters will be robust to this and most filters won't even be anticipating informational headers outside of decode100ContiueHeaders().
Activity
alyssawilk commentedon Jun 4, 2020
I think we had intended to support only one but if the spec says allow many we should probably allow many.
I thought we had a test for multiples somewhere which verified nothing whacky happened,
htuch commentedon Jun 4, 2020
Also related:
htuch commentedon Jun 5, 2020
Also, thanks to Uli on Slack, a more modern reference is https://tools.ietf.org/html/rfc7231#section-6.2
htuch commentedon Jun 5, 2020
The more I look at the spec, I'm becoming convinced that while multiple 1xx should be supported, i.e. different 1xx informational responses, but multiple 100 doesn't make any sense. It's not stated explicitly, but this seems to be a reasonable interpretation.
htuch commentedon Jun 7, 2020
Based on the RFC 7231 description "A client MUST be able to parse one or more 1xx responses received prior to a final response, even if the client does not expect one. A user agent MAY ignore unexpected 1xx responses." I'm going to go with "allow multiple 100 continues but ignore proxying all but the first.". I think this is the intended behavior today but the integration test in my PR seems to show that we need to do some work to avoid header/trailers confusion in this case.
alyssawilk commentedon Jun 8, 2020
obligatory @PiotrSikora :-)
antoniovicente commentedon Jun 8, 2020
We should fix brokenness while attempting to proxy multiple 1xx response headers. The first step could be a simpler change to fail if multiple 1xx responses are detected. I don't know how common multiple 1xx responses are; I can see a server replying with 100 followed by 103 or 102. I don't know how common 102 or 103 responses are: 103 is from an RFC published in 2017, 102 is part of webdav
htuch commentedon Jun 8, 2020
I think the spec suggests that the fix could be just ignoring unexpected headers. If we don't support 102, for example, then it's acceptable to ignore it, rather than fail. It would be good to clarify if failure semantics are preferred to ignoring semantics.
mattklein123 commentedon Jun 8, 2020
FWIW I suggest we keep it simple and (correctly) ignore all 1xx responses after the first. I think this was @alyssawilk's intention and I would just do this until someone complains about it.
htuch commentedon Jul 10, 2020
I have taken another shot at this in #12037. The idea now is to really ignore any 1xx that follow the initial 1xx. While working on tests, the treatment of non-100 1xx headers came up, and it seems it's a bit weird. Consider the following sequences of headers:
decode100ContinueHeaders()and then terminates on the 102 as we have multiple 1xx.decode100ContinueHeaders()and thendecodeHeaders().decodeHeaders()twice.I'm thinking it would be good to be more strict and/or clarify what happens to non-100 1xx. The following options seems possible:
decodeHeaders(). I think we do this today, but I didn't see a test.I think that (2) is a bit confusing, since almost always, for HTTP/1 and HTTP/2, we're seeing a single
decodeHeaders()in filters etc, but we have this corner edge case, which it's likely most folks won't anticipate.@alyssawilk @mattklein123 any thoughts here?
PiotrSikora commentedon Jul 10, 2020
Only
102 Processingand103 Early Hintsare informational and could be potentially discarded, but there is no reason why they should be, to be honest.100 Continueis critical and would break request flow if not forwarded downstream, though multiple100 Continuecould be collapsed into a single one (i.e. the first one would be forwarded, and subsequent100 Continuewould be ignored), but that's really the only case where we could ignore1xxresponse.101 Switching Protocolsis hop-by-hop, so I guess it doesn't matter too much here.alyssawilk commentedon Jul 13, 2020
The code as written was just to forward literal 100s followed by informational header, or 101 followed by upgrade.
101 is "special" insofar as there shouldn't be response headers after, so treating that like normal headers since they're the only response headers (and important) kind of makes sense to me.
Easiest would be to just drop other 1xx headers and document we don't support them. Less easy would be to support multiple other 1xx headers by some mechanism or other. I'm pretty neutral about that - 100-continue is needed for a bunch of things to work properly but I don't know of anyone who really requires 102 or 103.
htuch commentedon Jul 13, 2020
Based on what @alyssawilk and @PiotrSikora say, I'm going to go with drop, test and document this behavior. I'm pretty worried about having a
decodeHeaders()double invocation corner case, since not all filters will be robust to this and most filters won't even be anticipating informational headers outside ofdecode100ContiueHeaders().[WiP] http: fix handling of multiple 100-continue headers.
http: tighten handling of non-{100,101} 1xx and multiple 100 headers. (
http: tighten handling of non-{100,101} 1xx and multiple 100 headers. (