Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not reserialize XHR content-types unnecessarily
See whatwg/xhr#224.
- Loading branch information
1 parent
7cd5329
commit dd6c5a0
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/web-platform-tests/to-upstream/xhr/content-type-unmodified.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<title>A charset-including content-type header must not be modified (e.g. via reserialization)</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
async_test(t => { | ||
const xhr = new XMLHttpRequest(); | ||
|
||
xhr.open("POST", "resources/echo-content-type.py"); | ||
xhr.setRequestHeader("content-type", "application/json; charset=UTF-8"); | ||
|
||
xhr.onerror = t.unreached_func("Error occurred."); | ||
|
||
xhr.onload = t.step_func_done(() => { | ||
assert_equals(xhr.status, 200); | ||
assert_equals(xhr.responseText, "application/json; charset=UTF-8"); | ||
}); | ||
xhr.send("{ \"x\":\"a\"}"); | ||
}); | ||
</script> |
5 changes: 5 additions & 0 deletions
5
test/web-platform-tests/to-upstream/xhr/resources/echo-content-type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def main(request, response): | ||
response.headers.set("Content-Type", "text/plain") | ||
response.status = 200 | ||
response.content = request.headers["Content-Type"] | ||
response.close_connection = True |