Bug 815299 - Part 2: Accept empty HTTP headers in fetch; r=jdm

This commit is contained in:
Ehsan Akhgari 2015-08-27 10:14:03 -04:00
parent 13be7cbd93
commit 86169e290f
3 changed files with 23 additions and 1 deletions

View File

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

View File

@ -320,3 +320,12 @@ 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();
});

View File

@ -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"));
}
};