🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Test HTTP parsing - #5102

Open
annevk wants to merge 1 commit into
masterfrom
annevk/http-versioning
Open

annevk wants to merge 1 commit into
masterfrom
annevk/http-versioning

Conversation

@annevk

@annevk annevk commented Mar 9, 2017 •

Copy link
Copy Markdown
Member

Closes #5064.

@wpt-pr-bot wpt-pr-bot added the http label Mar 9, 2017
@annevk

annevk commented Mar 9, 2017

Copy link
Copy Markdown
Member Author

@mnot this is a mess. I guess I can change the pass conditions for a couple of these (though not entirely clear if they all should outright fail or do something else), but I wonder how much browsers are willing to change here. IETF should get a bit more serious about testing I think.

@zcorpan

zcorpan commented Mar 9, 2017

Copy link
Copy Markdown
Member

Result in Safari TP Release 24 (Safari 10.2, WebKit 12604.1.6)

Subtest Results Messages
OK
HTTP/0.7 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
HTTP/1.0 280 PASS
HTTP/1.11 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
HTTP/1.2 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
HTTP/1.7 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
HTTP/2.0 280 PASS
HTTP/5.garbage 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
splitonspace 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
http 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"
HttP/1.1 280 PASS
HTTP/garbage 280 FAIL promise_test: Unhandled rejection with value: object "TypeError: Type error"

<div id=log></div>
<script>
[
"HTTP/0.7 280",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP/0 is effectively HTTP/0.9, which doesn't have a status code. So, this should fail in some fashion.

"HTTP/1.11 280",
"HTTP/1.2 280",
"HTTP/1.7 280",
"HTTP/2.0 280",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP/!1 is a wire-incompatible with HTTP/1.x, so all bets are off for this and HTTP/5, etc. These should be errors, as should be plain "http" and "splitonspace".

"HTTP/5.garbage 280",
"splitonspace 280",
"http 280",
"HttP/1.1 280",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http-version is case-sensitive; this should be an error.

<script>
[
"HTTP/0.7 280",
"HTTP/1.0 280",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntactically, a reason-phrase is required; you might want to include them so you don't get false negatives.

@mnot

mnot commented Mar 9, 2017

Copy link
Copy Markdown
Member

There isn't any intention of introducing new versions of HTTP/1, because this phenomenon has been observed for a long time; there are lots of bits of software that get this wrong (not just browsers).

See also: https://tools.ietf.org/html/rfc2145#section-2

@mnot

mnot commented Mar 9, 2017

Copy link
Copy Markdown
Member

All of that said, I understand that there are some situations where browsers need to treat protocols specially, e.g., for ICECAST and a few others. @mcmanus might have some thoughts here.

@mcmanus

mcmanus commented Mar 9, 2017

Copy link
Copy Markdown

most of these non HTTP/1 cases are being interpreted as HTTP 0.9... which is fair enough - they aren't HTTP/1 and there is no version negotiation outside of the TCP stream. There is no response code in 0.9 so calling it 200 or parsing it and calling it 280 all seem fair game. Not a useful test.

The exception is the HTTP/2 case (in what is obviously not RFC 7540 HTTP2..).. as mark notes, that's just a bugwards accommodation for shoutcast to treat that as http/1. Similarly allowing mixed-case HttP is something that a receiver is just going to do for legacy interop. We've cleaned it up going forward

@annevk

annevk commented Mar 10, 2017

Copy link
Copy Markdown
Member Author

Right, it seems suspicious that all user agents support HTTP/2.0 and case-insensitive mostly worked.

There's also a difference between returning a network error and continuing to treat as HTTP/0.9 (the latter is what Firefox does and Edge maybe (although Edge uses the status code 520), the former is more like Safari and Chrome (although Chrome only does one scenario that way)).

So if some of this is required it would be good if the HTTP specification actually said so. Otherwise it's hard to come up with pass/fail criteria here and get browsers to align on how they handle pass/fail.

@annevk
annevk force-pushed the annevk/http-versioning branch from 7dcde16 to 7606bc9 Compare May 14, 2018 08:31
@wpt-pr-bot

Copy link
Copy Markdown
Collaborator

There are no owners for this pull request. Please reach out on W3C's irc server (irc.w3.org, port 6665) on channel #testing (web client) to get help with this. Thank you!

@web-platform-tests web-platform-tests deleted a comment May 14, 2018
@web-platform-tests web-platform-tests deleted a comment May 14, 2018
@gsnedders gsnedders closed this Jan 24, 2020
@gsnedders
gsnedders deleted the annevk/http-versioning branch January 24, 2020 18:01
@gsnedders
gsnedders restored the annevk/http-versioning branch January 24, 2020 18:47
@Hexcles Hexcles reopened this Jan 24, 2020
@nox

nox commented Mar 8, 2021

Copy link
Copy Markdown
Contributor

@MattMenke2 Could you tell me if Chrome uses the same HTTP parser in Fetch and in normal loads? And more generally, could you link me to the code, please?

@MattMenke2

Copy link
Copy Markdown
Member

Chrome uses the same HTTP parsers for all requests.

https://source.chromium.org/chromium/chromium/src/+/master:net/http/http_stream_parser.h is Chrome's HTTP/0.9 and HTTP/1.x parser (assume you don't also want H/2 or H/3 as those are much more complicated).

HttpStreamParser::FindAndParseResponseHeaders (https://source.chromium.org/chromium/chromium/src/+/master:net/http/http_stream_parser.cc;drc=6687e9201a1b0d2c9c81ad7e4dd113fb09547953;bpv=0;bpt=1;l=966) is the most relevant function, along with the HttpUtil/HttpResponseHeaders methods it calls, though need to go a level up if you want to dig into how Chrome deals with truncated responses.

There's a lot of allowance for incorrectly formatted headers that would be great if we could get rid of, but not sure how much interest there is in actively investing in it, since deprecations can involve a lot of legwork.

@nox

nox commented Mar 8, 2021

Copy link
Copy Markdown
Contributor

https://source.chromium.org/chromium/chromium/src/+/master:net/http/http_stream_parser.h is Chrome's HTTP/0.9 and HTTP/1.x parser (assume you don't also want H/2 or H/3 as those are much more complicated).

So Chrome does accept HTTP/0.9 responses? In which circumstances? I ran this PR and tried to load https://web-platform.test:8443/http/resources/version.py?input=splitonspace%20280 in Chrome and got a ERR_INVALID_HTTP_RESPONSE error page from the UA.

@nox

nox commented Mar 8, 2021

Copy link
Copy Markdown
Contributor

@MattMenke2

MattMenke2 commented Mar 8, 2021 •

Copy link
Copy Markdown
Member

Yea, other than on default ports, Chrome only allows HTTP/0.9 for Shoutcast responses ("ICY/...") over HTTP, because we got a bunch of bug reports about that when we disabled HTTP/0.9 on non-standard ports.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fetch: test HTTP/1.9 responses?

10 participants