Accept Brotli-compressed HTTP responses #8156

This commit is contained in:
nxnfufunezn 2015-10-31 01:25:16 +05:30
parent 959ae86bd0
commit 468eaac096
11 changed files with 97 additions and 9 deletions

View file

@ -35349,4 +35349,4 @@
"rev": "7123012427f92f0dc38a120e6e86a75b6c03aab5",
"url_base": "/",
"version": 2
}
}

View file

@ -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
}
}

View 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

View 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>