mirror of
https://github.com/servo/servo.git
synced 2025-09-10 15:08:21 +01:00
XMLHttpRequest
Send
: fix Content-Type failures (#38993)
Replaced usage of `typed_insert` since it ended converting `UTF-8` to lowercase. Removed one of the test cases since it wasn't following spec since [xhr/205](https://github.com/whatwg/xhr/pull/205). Testing: Changes covered by wpt Fixes: #20436 --------- Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
parent
cb64def7e6
commit
908c392219
5 changed files with 7 additions and 32 deletions
|
@ -739,7 +739,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let new_mime = format!(
|
let new_mime = format!(
|
||||||
"{}/{}; charset={}{}{}",
|
"{}/{};charset={}{}{}",
|
||||||
mime.type_,
|
mime.type_,
|
||||||
mime.subtype,
|
mime.subtype,
|
||||||
encoding,
|
encoding,
|
||||||
|
@ -750,9 +750,11 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("; ")
|
.join("; ")
|
||||||
);
|
);
|
||||||
request
|
|
||||||
.headers
|
request.headers.insert(
|
||||||
.typed_insert(ContentType::from_str(&new_mime).unwrap())
|
header::CONTENT_TYPE,
|
||||||
|
HeaderValue::from_str(&new_mime).unwrap(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
tests/wpt/meta/MANIFEST.json
vendored
2
tests/wpt/meta/MANIFEST.json
vendored
|
@ -922538,7 +922538,7 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"setrequestheader-content-type.htm": [
|
"setrequestheader-content-type.htm": [
|
||||||
"07238391eb5cc8639edbe996208a18b6d9d26b04",
|
"c78482142469cf966c3f64287c81c78bcd4f3e63",
|
||||||
[
|
[
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,17 +2,11 @@
|
||||||
[charset given but wrong, fix it (unknown MIME, bogus charset)]
|
[charset given but wrong, fix it (unknown MIME, bogus charset)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[charset given but wrong, fix it (known MIME, actual charset)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Multiple non-UTF-8 charset parameters deduplicate, bogus parameter dropped]
|
[Multiple non-UTF-8 charset parameters deduplicate, bogus parameter dropped]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[charset with leading space that is UTF-8 does change]
|
[charset with leading space that is UTF-8 does change]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[charset in double quotes with space]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[unknown parameters need to be preserved]
|
[unknown parameters need to be preserved]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
[setrequestheader-content-type.htm]
|
|
||||||
[String request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8]
|
|
||||||
expected: FAIL
|
|
|
@ -206,15 +206,6 @@
|
||||||
"application/x-www-form-urlencoded;charset=UTF-8",
|
"application/x-www-form-urlencoded;charset=UTF-8",
|
||||||
'URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8"'
|
'URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8"'
|
||||||
)
|
)
|
||||||
request(
|
|
||||||
function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") },
|
|
||||||
{"Content-Type": "application/xml;charset=ASCII"},
|
|
||||||
"application/xml;charset=UTF-8",
|
|
||||||
"URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8"
|
|
||||||
// the default Content-Type for URLSearchParams has a charset specified (utf-8) in
|
|
||||||
// https://fetch.spec.whatwg.org/#bodyinit, so the user's must be changed to match it
|
|
||||||
// as per https://xhr.spec.whatwg.org/#the-send%28%29-method step 4.
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue