Bug 1328761 part 2. Update some FetchDriver comments to more clearly reflect reality. r=bkelly

This commit is contained in:
Boris Zbarsky 2017-01-14 22:43:17 -05:00
Родитель aca020c034
Коммит dbb8879a4c
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -314,12 +314,22 @@ FetchDriver::HttpFetch()
nsAutoCString contentType;
ErrorResult result;
mRequest->Headers()->GetFirst(NS_LITERAL_CSTRING("content-type"), contentType, result);
// This is an error because the Request constructor explicitly extracts and
// sets a content-type per spec.
// We don't actually expect "result" to have failed here: that only happens
// for invalid header names. But if for some reason it did, just propagate
// it out.
if (result.Failed()) {
return result.StealNSResult();
}
// Now contentType is the header that was set in mRequest->Headers(), or a
// void string if no header was set.
#ifdef DEBUG
bool hasContentTypeHeader =
mRequest->Headers()->Has(NS_LITERAL_CSTRING("content-type"), result);
MOZ_ASSERT(!result.Failed());
MOZ_ASSERT_IF(!hasContentTypeHeader, contentType.IsVoid());
#endif // DEBUG
nsCOMPtr<nsIInputStream> bodyStream;
mRequest->GetBody(getter_AddRefs(bodyStream));
if (bodyStream) {