Skip to content

Commit

Permalink
Preserve UserAgent header on redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 12, 2015
1 parent c8c7bd9 commit 9a87f83
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
4 changes: 3 additions & 1 deletion components/net/resource_task.rs
Expand Up @@ -259,7 +259,9 @@ impl ResourceManager {
}
}

self.user_agent.as_ref().map(|ua| load_data.headers.set(UserAgent(ua.clone())));
self.user_agent.as_ref().map(|ua| {
load_data.preserved_headers.set(UserAgent(ua.clone()));
});

fn from_factory(factory: fn(LoadData, LoadConsumer, Arc<MIMEClassifier>))
-> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> {
Expand Down
4 changes: 3 additions & 1 deletion tests/wpt/harness/wptrunner/executors/executorservo.py
Expand Up @@ -62,7 +62,9 @@ def do_test(self, test):
self.result_data = None
self.result_flag = threading.Event()

debug_args, command = browser_command(self.binary, ["--cpu", "--hard-fail", "-z", self.test_url(test)],
debug_args, command = browser_command(self.binary, ["--cpu", "--hard-fail", "-z",
"-u", "Servo/wptrunner",
self.test_url(test)],
self.debug_info)

self.command = command
Expand Down
11 changes: 10 additions & 1 deletion tests/wpt/metadata/MANIFEST.json
Expand Up @@ -25117,7 +25117,16 @@
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"XMLHttpRequest/preserve-ua-header-on-redirect.htm": [
{
"path": "XMLHttpRequest/preserve-ua-header-on-redirect.htm",
"url": "/XMLHttpRequest/preserve-ua-header-on-redirect.htm"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {
Expand Down
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>XMLHttpRequest: User-Agent header is preserved on redirect</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
var ua = "Servo/wptrunner";
var test = async_test()
test.step(function() {
var client = new XMLHttpRequest()
client.onreadystatechange = function() {
test.step(function() {
if(client.readyState == 4) {
assert_equals(client.responseText, "user-agent,")
test.done()
}
})
}
client.open("POST", "resources/redirect.py?location="+encodeURIComponent("inspect-headers.py?filter_value="+ua))
client.send(null)
})
</script>
</body>
</html>

0 comments on commit 9a87f83

Please sign in to comment.