Bug 1217501 P2 Send */* for fetch() default Accept header. r=ehsan

This commit is contained in:
Ben Kelly 2015-10-26 08:25:16 -07:00
parent 51ad72c930
commit 9338a75577

View File

@ -303,7 +303,11 @@ FetchDriver::HttpFetch()
// Set the same headers.
nsAutoTArray<InternalHeaders::Entry, 5> headers;
mRequest->Headers()->GetEntries(headers);
bool hasAccept = false;
for (uint32_t i = 0; i < headers.Length(); ++i) {
if (!hasAccept && headers[i].mName.EqualsLiteral("accept")) {
hasAccept = true;
}
if (headers[i].mValue.IsEmpty()) {
httpChan->SetEmptyRequestHeader(headers[i].mName);
} else {
@ -311,6 +315,12 @@ FetchDriver::HttpFetch()
}
}
if (!hasAccept) {
httpChan->SetRequestHeader(NS_LITERAL_CSTRING("accept"),
NS_LITERAL_CSTRING("*/*"),
false /* merge */);
}
// Step 2. Set the referrer.
nsAutoString referrer;
mRequest->GetReferrer(referrer);