mirror of
https://github.com/servo/servo.git
synced 2025-10-01 09:09:15 +01:00
Auto merge of #8192 - nxnfufunezn:brotli-decompressor, r=jdm
Accept Brotli-compressed HTTP responses #8156 r? @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8192) <!-- Reviewable:end -->
This commit is contained in:
commit
2e4454a423
11 changed files with 97 additions and 9 deletions
|
@ -35349,4 +35349,4 @@
|
|||
"rev": "7123012427f92f0dc38a120e6e86a75b6c03aab5",
|
||||
"url_base": "/",
|
||||
"version": 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4567,6 +4567,12 @@
|
|||
"url": "/_mozilla/mozilla/proxy_setter.html"
|
||||
}
|
||||
],
|
||||
"mozilla/response-data-brotli.htm": [
|
||||
{
|
||||
"path": "mozilla/response-data-brotli.htm",
|
||||
"url": "/_mozilla/mozilla/response-data-brotli.htm"
|
||||
}
|
||||
],
|
||||
"mozilla/script_type.html": [
|
||||
{
|
||||
"path": "mozilla/script_type.html",
|
||||
|
@ -8730,4 +8736,4 @@
|
|||
"rev": null,
|
||||
"url_base": "/_mozilla/",
|
||||
"version": 2
|
||||
}
|
||||
}
|
7
tests/wpt/mozilla/tests/mozilla/resources/brotli.py
Normal file
7
tests/wpt/mozilla/tests/mozilla/resources/brotli.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
def main(request, response):
|
||||
output = '\x1b\x03)\x00\xa4\xcc\xde\xe2\xb3 vA\x00\x0c'
|
||||
headers = [("Content-type", "text/plain"),
|
||||
("Content-Encoding", "br"),
|
||||
("Content-Length", len(output))]
|
||||
|
||||
return headers, output
|
42
tests/wpt/mozilla/tests/mozilla/response-data-brotli.htm
Normal file
42
tests/wpt/mozilla/tests/mozilla/response-data-brotli.htm
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: Brotli response was correctly inflated</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::p[contains(text(),'content-encodings')]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function request(input) {
|
||||
var test = async_test();
|
||||
test.step(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
|
||||
client.open("POST", "resources/brotli.py", false);
|
||||
|
||||
client.onreadystatechange = test.step_func(function () {
|
||||
if (client.readyState === 4) {
|
||||
var len = parseInt(client.getResponseHeader('content-length'), 10);
|
||||
|
||||
assert_equals(client.getResponseHeader('content-encoding'), 'br');
|
||||
assert_true(len < input.length);
|
||||
assert_equals(client.responseText, input);
|
||||
test.done();
|
||||
}
|
||||
});
|
||||
|
||||
client.send(input);
|
||||
}, document.title);
|
||||
}
|
||||
|
||||
var wellCompressableData = '';
|
||||
for (var i = 0; i < 500; i++) {
|
||||
wellCompressableData += 'foofoofoofoofoofoofoo';
|
||||
}
|
||||
|
||||
request(wellCompressableData);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue