[eventsource] Do not send invalid HTTP response - #5037
Conversation
|
Notifying @Yaffle, @odinho, and @zqzhang. (Learn how reviewing works.) |
Firefox (nightly channel)Testing web-platform-tests at revision eec8e41 All results1 test ran/eventsource/request-status-error.htm
|
Chrome (unstable channel)Testing web-platform-tests at revision eec8e41 All results1 test ran/eventsource/request-status-error.htm
|
|
In the W3C's #testing IRC channel, @jgraham wrote:
I'm not so sure about this. @RByers I know interoperability has a special place |
Yeah, I think we should have negative tests where practical. Eg. we've talked about landing tests which validate a given API does NOT exist (eg. when it's been removed from a standard). I'd consider it a chromium bug whenever chromium is doing something explicitly prohibited by a spec. However, in some cases that may be lower priority than what the test is really trying to test - so pragmatically when we find such things it might make the most sense to move them to a separate test case to avoid failures in logically unrelated tests. Where things get tricky is when a specification leaves something implementation-defined. Often that's a spec bug (just not specified due to omission). Occasionally it's a pragmatic tradeoff where we've accepted that the cost of trying to achieve consensus isn't worth the benefit. In such cases we can't really have a WPT test, though I personally still consider it likely a chromium bug when chromium behaves differently from all other engines in such situations. Does that help in this case? |
|
I'm in total agreement. The conditions under consideration here are unexpected Don't get me wrong: I would love it if this effort actually resulted in an |
|
I see, thanks. The most important thing here is to try to improve interop of implementations and leverage the knowledge you've gained. So at a minimum, please file a chromium bug describing how Chrome behaved differently from Firefox (and ideally other browsers?). Ping me the bug number and I'll add a comment / label encouraging the network team to look into the options (including removing the opportunity for implementation-defined behavior from the relevant spec). If there's no per-spec behavior to test here in WPT around this then so be it. |
|
After still further research, I have learned that this behavior is neither a It seems that Python request handlers share some state. This allows the master...bocoup:serve-bug-demo The reduction may make this condition seem kind of arcane, but this basic The problem is observable if the body happens to be written to the wire in a In case ASCII art would help (and really, when wouldn't it?), here's a So this patch is valid, and beyond beyond semantically correct, it does in fact |
|
I don't think this patch is valid, since we want in fact be testing 204/205 responses with bodies. What exactly happens with the second TCP packet? If the connection is still open, Chrome should be able to handle it. Otherwise Chrome should have closed the connection early or some such. |
|
Note also that behavior for 204/205 with bodies is in fact defined by https://fetch.spec.whatwg.org/. |
Oh, okay. I have to admit that even after 2 weeks of working with this test,
If the connection is still open, Chrome tolerates the extra data (although the The problem with the infrastructure is only appreciable when Chrome closes |
|
FWIW, what you suggest is fine, but we routinely do invalid things when the behavior is well-defined (as I mentioned, Fetch describes how to handle this). So I think just fixing the infrastructure is fine too and probably more consistent with our overall approach. |
|
@annevk I've opened #5227 to |
| return status, headers, "data: data\n\n" | ||
|
|
||
| # According to RFC7231, HTTP responses bearing status code 204 or 205 must | ||
| # not specify a body. |
There was a problem hiding this comment.
Could you please update this with a reference to the issue instead? What the RFC says is conforming does not matter much with respect to how implementations have to handle the situation where it happens anyway.
There was a problem hiding this comment.
Sure. I've kept the reference to the RFC so that readers have the whole context.
|
LGTM, but I cannot merge this due to Travis. |
HTTP responses bearing status codes 204 and 205 MUST NOT include a body [1] [2]. In violating this restriction, the previous implementation of this test triggered unspecified behavior, which led to instability in the Chromium web browser. Update the test's request handler to omit a body for such responses. [1] https://tools.ietf.org/html/rfc7231#section-6.3.5 reads: > A 204 response is terminated by the first empty line after the header > fields because it cannot contain a message body. [2] https://tools.ietf.org/html/rfc7231#section-6.3.6 reads > Since the 205 status code implies that no additional content will be > provided, a server MUST NOT generate a payload in a 205 response.
2c84396 to
398b3e1
Compare
|
That's very odd. I've rebased, squashed and force-pushed the result to this branch (original available here); that seems to have fixed the issue. @jgraham check out the two "check stability" jobs in this build: https://travis-ci.org/w3c/web-platform-tests/builds/216048041 I can see two separate issues here. First, the script interpreted all the new CSS tests as part of the branch. Second, the output was mot truncated when it reached the TravisCI-imposed limit. Can you think of a reason why either of these things would happen? |
|
Where does the convention of the [ and ] in commit titles come from? Seen it a few times now. |
|
I don't think there is precedence for it in this project. It's something I started to follow when submitting multiple patches with similar intentions whose subject lines would otherwise be indistinguishable (e.g. "Remove duplicate test names"). That's not the case here, but in the absence of any guidelines (and with the characters to spare), I figured it couldn't hurt. |
|
@jgraham It looks like I made an error in my earlier comment:
The second issue is not actually occurring here. While the TravisCI UI is not rendering the full log, the output itself was correctly truncated, and the job failed due to the script's exit status. So the problem here is limited to the first issue I described. |
HTTP responses bearing status codes 204 and 205 MUST NOT include a body
[1] [2]. In violating this restriction, the previous implementation of
this test triggered unspecified behavior, which led to instability in
the Chromium web browser.
Update the test's request handler to omit a body for such responses.
[1] https://tools.ietf.org/html/rfc7231#section-6.3.5 reads:
[2] https://tools.ietf.org/html/rfc7231#section-6.3.6 reads