mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 815299 - Part 2: Accept empty HTTP headers in fetch; r=jdm
This commit is contained in:
parent
90f77f08b9
commit
0d3d9044a6
@ -477,7 +477,11 @@ FetchDriver::HttpFetch(bool aCORSFlag, bool aCORSPreflightFlag, bool aAuthentica
|
||||
nsAutoTArray<InternalHeaders::Entry, 5> headers;
|
||||
mRequest->Headers()->GetEntries(headers);
|
||||
for (uint32_t i = 0; i < headers.Length(); ++i) {
|
||||
httpChan->SetRequestHeader(headers[i].mName, headers[i].mValue, false /* merge */);
|
||||
if (headers[i].mValue.IsEmpty()) {
|
||||
httpChan->SetEmptyRequestHeader(headers[i].mName);
|
||||
} else {
|
||||
httpChan->SetRequestHeader(headers[i].mName, headers[i].mValue, false /* merge */);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2. Set the referrer.
|
||||
|
@ -320,3 +320,15 @@ fetch(new Request('body-blob', {method: 'POST', body: new Blob(new String('my bo
|
||||
finish();
|
||||
});
|
||||
});
|
||||
|
||||
expectAsyncResult();
|
||||
fetch(new Request('empty-header', {headers:{"emptyheader":""}}))
|
||||
.then(function(res) {
|
||||
return res.text();
|
||||
}).then(function(body) {
|
||||
my_ok(body == "emptyheader", "The empty header was observed in the fetch event");
|
||||
finish();
|
||||
}, function(err) {
|
||||
my_ok(false, "A promise was rejected with " + err);
|
||||
finish();
|
||||
});
|
||||
|
@ -274,4 +274,13 @@ onfetch = function(ev) {
|
||||
else if (ev.request.url.includes('xhr-method-test.txt')) {
|
||||
ev.respondWith(new Response('intercepted ' + ev.request.method));
|
||||
}
|
||||
|
||||
else if (ev.request.url.includes('empty-header')) {
|
||||
if (!ev.request.headers.has("emptyheader") ||
|
||||
ev.request.headers.get("emptyheader") !== "") {
|
||||
ev.respondWith(Promise.reject());
|
||||
return;
|
||||
}
|
||||
ev.respondWith(new Response("emptyheader"));
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user