Skip to content

Commit 55d6187

Browse files
committed
HTTP/1 parsing of responses without newlines after headers
For whatwg/fetch#472.
1 parent 5cbf4a1 commit 55d6187

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: fetch/h1-parsing/incomplete-response.window.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This only tests headers without a single newline after them for now.
2+
// See https://github.com/whatwg/fetch/issues/472 for context.
3+
4+
const statusLine = "HTTP/1.1 200 OKAYISH\n";
5+
6+
[
7+
"header: value\t",
8+
"header: value ",
9+
"header: value\f",
10+
"header: value\r"
11+
].forEach(input => {
12+
promise_test(t => {
13+
const message = encodeURIComponent(statusLine + input)
14+
return promise_rejects_js(t, TypeError, fetch(`resources/message.py?message=${message}`));
15+
}, `Parsing response without trailing newline (${input})`);
16+
});

Diff for: fetch/h1-parsing/resources/message.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def main(request, response):
2+
response.writer.write(request.GET.first(b"message"))
3+
response.close_connection = True

0 commit comments

Comments
 (0)