Skip to content

Commit

Permalink
HTTP/1 parsing of responses without newlines after headers
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Feb 3, 2021
1 parent 5cbf4a1 commit 55d6187
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fetch/h1-parsing/incomplete-response.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This only tests headers without a single newline after them for now.
// See https://github.com/whatwg/fetch/issues/472 for context.

const statusLine = "HTTP/1.1 200 OKAYISH\n";

[
"header: value\t",
"header: value ",
"header: value\f",
"header: value\r"
].forEach(input => {
promise_test(t => {
const message = encodeURIComponent(statusLine + input)
return promise_rejects_js(t, TypeError, fetch(`resources/message.py?message=${message}`));
}, `Parsing response without trailing newline (${input})`);
});
3 changes: 3 additions & 0 deletions fetch/h1-parsing/resources/message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def main(request, response):
response.writer.write(request.GET.first(b"message"))
response.close_connection = True

0 comments on commit 55d6187

Please sign in to comment.