Bug 1310127 - Part 17: Use MOZ_MUST_USE in netwerk/protocol/http r=smaug

MozReview-Commit-ID: 5gvVZtsa3yS

--HG--
extra : rebase_source : 5e1ab2fc06ae58f18abb8909ac93f9512abbe220
This commit is contained in:
Wei-Cheng Pan 2016-12-20 11:49:32 +08:00
parent 29f4cc8d4a
commit 510ba75c20
22 changed files with 144 additions and 85 deletions

View file

@ -995,18 +995,22 @@ EventSourceImpl::SetupHttpChannel()
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
MOZ_ASSERT(!IsShutDown()); MOZ_ASSERT(!IsShutDown());
mHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("GET")); DebugOnly<nsresult> rv =
mHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("GET"));
MOZ_ASSERT(NS_SUCCEEDED(rv));
/* set the http request headers */ /* set the http request headers */
mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
NS_LITERAL_CSTRING(TEXT_EVENT_STREAM), false); NS_LITERAL_CSTRING(TEXT_EVENT_STREAM), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
// LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header // LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header
if (!mLastEventID.IsEmpty()) { if (!mLastEventID.IsEmpty()) {
mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"), rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"),
NS_ConvertUTF16toUTF8(mLastEventID), false); NS_ConvertUTF16toUTF8(mLastEventID), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }

View file

@ -1349,7 +1349,8 @@ Navigator::SendBeaconInternal(const nsAString& aUrl,
aRv.Throw(NS_ERROR_DOM_BAD_URI); aRv.Throw(NS_ERROR_DOM_BAD_URI);
return false; return false;
} }
httpChannel->SetReferrer(documentURI); rv = httpChannel->SetReferrer(documentURI);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIInputStream> in; nsCOMPtr<nsIInputStream> in;
nsAutoCString contentTypeWithCharset; nsAutoCString contentTypeWithCharset;
@ -1379,7 +1380,8 @@ Navigator::SendBeaconInternal(const nsAString& aUrl,
NS_LITERAL_CSTRING("POST"), NS_LITERAL_CSTRING("POST"),
false); false);
} else { } else {
httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST")); rv = httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(channel); nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(channel);

View file

@ -2638,11 +2638,11 @@ nsDocument::InitCSP(nsIChannel* aChannel)
} }
if (httpChannel) { if (httpChannel) {
httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("content-security-policy"), NS_LITERAL_CSTRING("content-security-policy"),
tCspHeaderValue); tCspHeaderValue);
httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("content-security-policy-report-only"), NS_LITERAL_CSTRING("content-security-policy-report-only"),
tCspROHeaderValue); tCspROHeaderValue);
} }
@ -4796,7 +4796,8 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
do_QueryInterface(GetChannel()); do_QueryInterface(GetChannel());
if (internalChannel) { if (internalChannel) {
nsCOMArray<nsISecurityConsoleMessage> messages; nsCOMArray<nsISecurityConsoleMessage> messages;
internalChannel->TakeAllSecurityMessages(messages); DebugOnly<nsresult> rv = internalChannel->TakeAllSecurityMessages(messages);
MOZ_ASSERT(NS_SUCCEEDED(rv));
SendToConsole(messages); SendToConsole(messages);
} }

View file

@ -2599,8 +2599,9 @@ nsObjectLoadingContent::OpenChannel()
// Referrer // Referrer
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan)); nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
if (httpChan) { if (httpChan) {
httpChan->SetReferrerWithPolicy(doc->GetDocumentURI(), rv = httpChan->SetReferrerWithPolicy(doc->GetDocumentURI(),
doc->GetReferrerPolicy()); doc->GetReferrerPolicy());
MOZ_ASSERT(NS_SUCCEEDED(rv));
// Set the initiator type // Set the initiator type
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChan)); nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChan));

View file

@ -1298,15 +1298,18 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest)
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) { if (httpChannel) {
// HTTP content negotation has little value in this context. // HTTP content negotation has little value in this context.
httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
NS_LITERAL_CSTRING("*/*"), NS_LITERAL_CSTRING("*/*"),
false); false);
httpChannel->SetReferrerWithPolicy(mDocument->GetDocumentURI(), MOZ_ASSERT(NS_SUCCEEDED(rv));
aRequest->mReferrerPolicy); rv = httpChannel->SetReferrerWithPolicy(mDocument->GetDocumentURI(),
aRequest->mReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIHttpChannelInternal> internalChannel(do_QueryInterface(httpChannel)); nsCOMPtr<nsIHttpChannelInternal> internalChannel(do_QueryInterface(httpChannel));
if (internalChannel) { if (internalChannel) {
internalChannel->SetIntegrityMetadata(aRequest->mIntegrity.GetIntegrityString()); rv = internalChannel->SetIntegrityMetadata(aRequest->mIntegrity.GetIntegrityString());
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }

View file

@ -143,15 +143,17 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
mChannel = aChannel; mChannel = aChannel;
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(mChannel); nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(mChannel);
if (http) { if (http) {
http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), rv = http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"), NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"),
false); false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) { if (loadInfo) {
nsCOMPtr<nsIURI> loaderUri; nsCOMPtr<nsIURI> loaderUri;
loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri)); loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri));
if (loaderUri) { if (loaderUri) {
http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy); rv = http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
} }

View file

@ -298,11 +298,15 @@ FetchDriver::HttpFetch()
// Conversion between enumerations is safe due to static asserts in // Conversion between enumerations is safe due to static asserts in
// dom/workers/ServiceWorkerManager.cpp // dom/workers/ServiceWorkerManager.cpp
internalChan->SetCorsMode(static_cast<uint32_t>(mRequest->Mode())); rv = internalChan->SetCorsMode(static_cast<uint32_t>(mRequest->Mode()));
internalChan->SetRedirectMode(static_cast<uint32_t>(mRequest->GetRedirectMode())); MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = internalChan->SetRedirectMode(static_cast<uint32_t>(mRequest->GetRedirectMode()));
MOZ_ASSERT(NS_SUCCEEDED(rv));
mRequest->MaybeSkipCacheIfPerformingRevalidation(); mRequest->MaybeSkipCacheIfPerformingRevalidation();
internalChan->SetFetchCacheMode(static_cast<uint32_t>(mRequest->GetCacheMode())); rv = internalChan->SetFetchCacheMode(static_cast<uint32_t>(mRequest->GetCacheMode()));
internalChan->SetIntegrityMetadata(mRequest->GetIntegrity()); MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = internalChan->SetIntegrityMetadata(mRequest->GetIntegrity());
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
// Step 5. Proxy authentication will be handled by Necko. // Step 5. Proxy authentication will be handled by Necko.
@ -451,7 +455,8 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
if (httpChannel) { if (httpChannel) {
uint32_t responseStatus; uint32_t responseStatus;
httpChannel->GetResponseStatus(&responseStatus); rv = httpChannel->GetResponseStatus(&responseStatus);
MOZ_ASSERT(NS_SUCCEEDED(rv));
if (mozilla::net::nsHttpChannel::IsRedirectStatus(responseStatus)) { if (mozilla::net::nsHttpChannel::IsRedirectStatus(responseStatus)) {
if (mRequest->GetRedirectMode() == RequestRedirect::Error) { if (mRequest->GetRedirectMode() == RequestRedirect::Error) {
@ -464,7 +469,8 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
} }
nsAutoCString statusText; nsAutoCString statusText;
httpChannel->GetResponseStatusText(statusText); rv = httpChannel->GetResponseStatusText(statusText);
MOZ_ASSERT(NS_SUCCEEDED(rv));
response = new InternalResponse(responseStatus, statusText); response = new InternalResponse(responseStatus, statusText);
@ -739,8 +745,8 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
nsCOMPtr<nsIHttpChannel> oldHttpChannel = do_QueryInterface(aOldChannel); nsCOMPtr<nsIHttpChannel> oldHttpChannel = do_QueryInterface(aOldChannel);
nsAutoCString tRPHeaderCValue; nsAutoCString tRPHeaderCValue;
if (oldHttpChannel) { if (oldHttpChannel) {
oldHttpChannel->GetResponseHeader(NS_LITERAL_CSTRING("referrer-policy"), Unused << oldHttpChannel->GetResponseHeader(NS_LITERAL_CSTRING("referrer-policy"),
tRPHeaderCValue); tRPHeaderCValue);
} }
// "HTTP-redirect fetch": step 14 "Append locationURL to request's URL list." // "HTTP-redirect fetch": step 14 "Append locationURL to request's URL list."
@ -836,24 +842,32 @@ FetchDriver::SetRequestHeaders(nsIHttpChannel* aChannel) const
hasAccept = true; hasAccept = true;
} }
if (headers[i].mValue.IsEmpty()) { if (headers[i].mValue.IsEmpty()) {
aChannel->SetEmptyRequestHeader(headers[i].mName); DebugOnly<nsresult> rv = aChannel->SetEmptyRequestHeader(headers[i].mName);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} else { } else {
aChannel->SetRequestHeader(headers[i].mName, headers[i].mValue, false /* merge */); DebugOnly<nsresult> rv =
aChannel->SetRequestHeader(headers[i].mName, headers[i].mValue,
false /* merge */);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
if (!hasAccept) { if (!hasAccept) {
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("accept"), DebugOnly<nsresult> rv =
NS_LITERAL_CSTRING("*/*"), aChannel->SetRequestHeader(NS_LITERAL_CSTRING("accept"),
false /* merge */); NS_LITERAL_CSTRING("*/*"),
false /* merge */);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
if (mRequest->ForceOriginHeader()) { if (mRequest->ForceOriginHeader()) {
nsAutoString origin; nsAutoString origin;
if (NS_SUCCEEDED(nsContentUtils::GetUTFOrigin(mPrincipal, origin))) { if (NS_SUCCEEDED(nsContentUtils::GetUTFOrigin(mPrincipal, origin))) {
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("origin"), DebugOnly<nsresult> rv =
NS_ConvertUTF16toUTF8(origin), aChannel->SetRequestHeader(NS_LITERAL_CSTRING("origin"),
false /* merge */); NS_ConvertUTF16toUTF8(origin),
false /* merge */);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
} }

View file

@ -148,7 +148,7 @@ FetchUtil::SetRequestReferrer(nsIPrincipal* aPrincipal,
} }
nsCOMPtr<nsIURI> referrerURI; nsCOMPtr<nsIURI> referrerURI;
aChannel->GetReferrer(getter_AddRefs(referrerURI)); Unused << aChannel->GetReferrer(getter_AddRefs(referrerURI));
// Step 8 https://fetch.spec.whatwg.org/#main-fetch // Step 8 https://fetch.spec.whatwg.org/#main-fetch
// If requests referrer is not "no-referrer", set requests referrer to // If requests referrer is not "no-referrer", set requests referrer to

View file

@ -355,7 +355,10 @@ InternalHeaders::FillResponseHeaders(nsIRequest* aRequest)
} }
RefPtr<FillHeaders> visitor = new FillHeaders(this); RefPtr<FillHeaders> visitor = new FillHeaders(this);
httpChannel->VisitResponseHeaders(visitor); nsresult rv = httpChannel->VisitResponseHeaders(visitor);
if (NS_FAILED(rv)) {
NS_WARNING("failed to fill headers");
}
} }
bool bool

View file

@ -291,7 +291,9 @@ HttpServer::TransportProvider::MaybeNotify()
RefPtr<TransportProvider> self = this; RefPtr<TransportProvider> self = this;
nsCOMPtr<nsIRunnable> event = NS_NewRunnableFunction([self, this] () nsCOMPtr<nsIRunnable> event = NS_NewRunnableFunction([self, this] ()
{ {
mListener->OnTransportAvailable(mTransport, mInput, mOutput); DebugOnly<nsresult> rv = mListener->OnTransportAvailable(mTransport,
mInput, mOutput);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}); });
NS_DispatchToCurrentThread(event); NS_DispatchToCurrentThread(event);
} }

View file

@ -516,7 +516,7 @@ HTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* aRequest,
if (hc && NS_SUCCEEDED(hc->GetRequestSucceeded(&succeeded)) && !succeeded) { if (hc && NS_SUCCEEDED(hc->GetRequestSucceeded(&succeeded)) && !succeeded) {
element->NotifyLoadError(); element->NotifyLoadError();
uint32_t responseStatus = 0; uint32_t responseStatus = 0;
hc->GetResponseStatus(&responseStatus); Unused << hc->GetResponseStatus(&responseStatus);
nsAutoString code; nsAutoString code;
code.AppendInt(responseStatus); code.AppendInt(responseStatus);
nsAutoString src; nsAutoString src;
@ -1168,9 +1168,10 @@ public:
// Use a byte range request from the start of the resource. // Use a byte range request from the start of the resource.
// This enables us to detect if the stream supports byte range // This enables us to detect if the stream supports byte range
// requests, and therefore seeking, early. // requests, and therefore seeking, early.
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rv = hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"),
NS_LITERAL_CSTRING("bytes=0-"), NS_LITERAL_CSTRING("bytes=0-"),
false); false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
aElement->SetRequestHeaders(hc); aElement->SetRequestHeaders(hc);
} }
@ -6454,12 +6455,15 @@ void HTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel)
// and a length spec in the container are not present either) and from seeking. // and a length spec in the container are not present either) and from seeking.
// So, disable the standard "Accept-Encoding: gzip,deflate" that we usually send. // So, disable the standard "Accept-Encoding: gzip,deflate" that we usually send.
// See bug 614760. // See bug 614760.
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"), DebugOnly<nsresult> rv =
EmptyCString(), false); aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"),
EmptyCString(), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
// Set the Referer header // Set the Referer header
aChannel->SetReferrerWithPolicy(OwnerDoc()->GetDocumentURI(), rv = aChannel->SetReferrerWithPolicy(OwnerDoc()->GetDocumentURI(),
OwnerDoc()->GetReferrerPolicy()); OwnerDoc()->GetReferrerPolicy());
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
void HTMLMediaElement::FireTimeUpdate(bool aPeriodic) void HTMLMediaElement::FireTimeUpdate(bool aPeriodic)

View file

@ -188,9 +188,9 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
bool seekable = false; bool seekable = false;
if (hc) { if (hc) {
uint32_t responseStatus = 0; uint32_t responseStatus = 0;
hc->GetResponseStatus(&responseStatus); Unused << hc->GetResponseStatus(&responseStatus);
bool succeeded = false; bool succeeded = false;
hc->GetRequestSucceeded(&succeeded); Unused << hc->GetRequestSucceeded(&succeeded);
if (!succeeded && NS_SUCCEEDED(status)) { if (!succeeded && NS_SUCCEEDED(status)) {
// HTTP-level error (e.g. 4xx); treat this as a fatal network-level error. // HTTP-level error (e.g. 4xx); treat this as a fatal network-level error.
@ -217,8 +217,8 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
} }
nsAutoCString ranges; nsAutoCString ranges;
hc->GetResponseHeader(NS_LITERAL_CSTRING("Accept-Ranges"), Unused << hc->GetResponseHeader(NS_LITERAL_CSTRING("Accept-Ranges"),
ranges); ranges);
bool acceptsRanges = ranges.EqualsLiteral("bytes"); bool acceptsRanges = ranges.EqualsLiteral("bytes");
// True if this channel will not return an unbounded amount of data // True if this channel will not return an unbounded amount of data
bool dataIsBounded = false; bool dataIsBounded = false;

View file

@ -154,7 +154,8 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel,
new PerformanceResourceTiming(performanceTiming, this, entryName); new PerformanceResourceTiming(performanceTiming, this, entryName);
nsAutoCString protocol; nsAutoCString protocol;
channel->GetProtocolVersion(protocol); // Can be an empty string.
Unused << channel->GetProtocolVersion(protocol);
// If this is a local fetch, nextHopProtocol should be set to empty string. // If this is a local fetch, nextHopProtocol should be set to empty string.
nsCOMPtr<nsICacheInfoChannel> cachedChannel = do_QueryInterface(channel); nsCOMPtr<nsICacheInfoChannel> cachedChannel = do_QueryInterface(channel);
@ -169,15 +170,15 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel,
performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol)); performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol));
uint64_t encodedBodySize = 0; uint64_t encodedBodySize = 0;
channel->GetEncodedBodySize(&encodedBodySize); Unused << channel->GetEncodedBodySize(&encodedBodySize);
performanceEntry->SetEncodedBodySize(encodedBodySize); performanceEntry->SetEncodedBodySize(encodedBodySize);
uint64_t transferSize = 0; uint64_t transferSize = 0;
channel->GetTransferSize(&transferSize); Unused << channel->GetTransferSize(&transferSize);
performanceEntry->SetTransferSize(transferSize); performanceEntry->SetTransferSize(transferSize);
uint64_t decodedBodySize = 0; uint64_t decodedBodySize = 0;
channel->GetDecodedBodySize(&decodedBodySize); Unused << channel->GetDecodedBodySize(&decodedBodySize);
if (decodedBodySize == 0) { if (decodedBodySize == 0) {
decodedBodySize = encodedBodySize; decodedBodySize = encodedBodySize;
} }

View file

@ -777,7 +777,8 @@ nsPluginStreamListenerPeer::RequestRead(NPByteRange* rangeList)
if (!httpChannel) if (!httpChannel)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, false); rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mAbort = true; // instruct old stream listener to cancel mAbort = true; // instruct old stream listener to cancel
// the request on the next ODA. // the request on the next ODA.
@ -1174,7 +1175,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
} }
// Also provide all HTTP response headers to our listener. // Also provide all HTTP response headers to our listener.
httpChannel->VisitResponseHeaders(this); rv = httpChannel->VisitResponseHeaders(this);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mSeekable = false; mSeekable = false;
// first we look for a content-encoding header. If we find one, we tell the // first we look for a content-encoding header. If we find one, we tell the

View file

@ -1000,7 +1000,8 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
// if this is an HTTP channel, set the request method to post // if this is an HTTP channel, set the request method to post
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(reportChannel)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(reportChannel));
if (httpChannel) { if (httpChannel) {
httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST")); rv = httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
RefPtr<CSPViolationReportListener> listener = new CSPViolationReportListener(); RefPtr<CSPViolationReportListener> listener = new CSPViolationReportListener();

View file

@ -325,7 +325,8 @@ DoContentSecurityChecks(nsIChannel* aChannel, nsILoadInfo* aLoadInfo)
= do_QueryInterface(aChannel); = do_QueryInterface(aChannel);
MOZ_ASSERT(httpChannelInternal); MOZ_ASSERT(httpChannelInternal);
if (httpChannelInternal) { if (httpChannelInternal) {
httpChannelInternal->GetProxyURI(getter_AddRefs(uri)); rv = httpChannelInternal->GetProxyURI(getter_AddRefs(uri));
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
mimeTypeGuess = EmptyCString(); mimeTypeGuess = EmptyCString();
requestingContext = aLoadInfo->LoadingNode(); requestingContext = aLoadInfo->LoadingNode();

View file

@ -1062,15 +1062,15 @@ private:
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("content-security-policy"), NS_LITERAL_CSTRING("content-security-policy"),
tCspHeaderValue); tCspHeaderValue);
httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("content-security-policy-report-only"), NS_LITERAL_CSTRING("content-security-policy-report-only"),
tCspROHeaderValue); tCspROHeaderValue);
httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("referrer-policy"), NS_LITERAL_CSTRING("referrer-policy"),
tRPHeaderCValue); tRPHeaderCValue);
} }

View file

@ -1384,7 +1384,8 @@ public:
nsAutoCString referrer; nsAutoCString referrer;
// Ignore the return value since the Referer header may not exist. // Ignore the return value since the Referer header may not exist.
httpChannel->GetRequestHeader(NS_LITERAL_CSTRING("Referer"), referrer); Unused << httpChannel->GetRequestHeader(NS_LITERAL_CSTRING("Referer"),
referrer);
if (!referrer.IsEmpty()) { if (!referrer.IsEmpty()) {
mReferrer = referrer; mReferrer = referrer;
} else { } else {
@ -1439,15 +1440,18 @@ public:
// This is safe due to static_asserts in ServiceWorkerManager.cpp. // This is safe due to static_asserts in ServiceWorkerManager.cpp.
uint32_t redirectMode; uint32_t redirectMode;
internalChannel->GetRedirectMode(&redirectMode); rv = internalChannel->GetRedirectMode(&redirectMode);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mRequestRedirect = static_cast<RequestRedirect>(redirectMode); mRequestRedirect = static_cast<RequestRedirect>(redirectMode);
// This is safe due to static_asserts in ServiceWorkerManager.cpp. // This is safe due to static_asserts in ServiceWorkerManager.cpp.
uint32_t cacheMode; uint32_t cacheMode;
internalChannel->GetFetchCacheMode(&cacheMode); rv = internalChannel->GetFetchCacheMode(&cacheMode);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mCacheMode = static_cast<RequestCache>(cacheMode); mCacheMode = static_cast<RequestCache>(cacheMode);
internalChannel->GetIntegrityMetadata(mIntegrity); rv = internalChannel->GetIntegrityMetadata(mIntegrity);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mRequestCredentials = InternalRequest::MapChannelToRequestCredentials(channel); mRequestCredentials = InternalRequest::MapChannelToRequestCredentials(channel);

View file

@ -671,11 +671,13 @@ CompareNetwork::Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsIL
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel); nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (httpChannel) { if (httpChannel) {
// Spec says no redirects allowed for SW scripts. // Spec says no redirects allowed for SW scripts.
httpChannel->SetRedirectionLimit(0); rv = httpChannel->SetRedirectionLimit(0);
MOZ_ASSERT(NS_SUCCEEDED(rv));
httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Service-Worker"), rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Service-Worker"),
NS_LITERAL_CSTRING("script"), NS_LITERAL_CSTRING("script"),
/* merge */ false); /* merge */ false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
nsCOMPtr<nsIStreamLoader> loader; nsCOMPtr<nsIStreamLoader> loader;
@ -765,7 +767,7 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext
// Get the stringified numeric status code, not statusText which could be // Get the stringified numeric status code, not statusText which could be
// something misleading like OK for a 404. // something misleading like OK for a 404.
uint32_t status = 0; uint32_t status = 0;
httpChannel->GetResponseStatus(&status); // don't care if this fails, use 0. Unused << httpChannel->GetResponseStatus(&status); // don't care if this fails, use 0.
nsAutoString statusAsText; nsAutoString statusAsText;
statusAsText.AppendInt(status); statusAsText.AppendInt(status);

View file

@ -1008,7 +1008,7 @@ XMLHttpRequestMainThread::GetStatusText(nsACString& aStatusText,
nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel(); nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel();
if (httpChannel) { if (httpChannel) {
httpChannel->GetResponseStatusText(aStatusText); Unused << httpChannel->GetResponseStatusText(aStatusText);
} else { } else {
aStatusText.AssignLiteral("OK"); aStatusText.AssignLiteral("OK");
} }
@ -1179,7 +1179,7 @@ XMLHttpRequestMainThread::IsSafeHeader(const nsACString& aHeader,
nsAutoCString headerVal; nsAutoCString headerVal;
// The "Access-Control-Expose-Headers" header contains a comma separated // The "Access-Control-Expose-Headers" header contains a comma separated
// list of method names. // list of method names.
aHttpChannel-> Unused << aHttpChannel->
GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Expose-Headers"), GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Expose-Headers"),
headerVal); headerVal);
nsCCharSeparatedTokenizer exposeTokens(headerVal, ','); nsCCharSeparatedTokenizer exposeTokens(headerVal, ',');
@ -1631,7 +1631,8 @@ XMLHttpRequestMainThread::PopulateNetworkInterfaceId()
if (!channel) { if (!channel) {
return; return;
} }
channel->SetNetworkInterfaceId(mNetworkInterfaceId); DebugOnly<nsresult> rv = channel->SetNetworkInterfaceId(mNetworkInterfaceId);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
/* /*
@ -2024,7 +2025,8 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
if (parseBody && httpChannel) { if (parseBody && httpChannel) {
nsAutoCString method; nsAutoCString method;
httpChannel->GetRequestMethod(method); rv = httpChannel->GetRequestMethod(method);
MOZ_ASSERT(NS_SUCCEEDED(rv));
parseBody = !method.EqualsLiteral("HEAD"); parseBody = !method.EqualsLiteral("HEAD");
} }
@ -2627,7 +2629,8 @@ XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
uploadChannel->SetUploadStream(aUploadStream, aUploadContentType, uploadChannel->SetUploadStream(aUploadStream, aUploadContentType,
mUploadTotal); mUploadTotal);
// Reset the method to its original value // Reset the method to its original value
httpChannel->SetRequestMethod(mRequestMethod); rv = httpChannel->SetRequestMethod(mRequestMethod);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
} }
@ -2654,7 +2657,8 @@ XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
nsCOMPtr<nsIHttpChannelInternal> nsCOMPtr<nsIHttpChannelInternal>
internalHttpChannel(do_QueryInterface(mChannel)); internalHttpChannel(do_QueryInterface(mChannel));
if (internalHttpChannel) { if (internalHttpChannel) {
internalHttpChannel->SetResponseTimeoutEnabled(false); rv = internalHttpChannel->SetResponseTimeoutEnabled(false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
if (!mIsAnon) { if (!mIsAnon) {
@ -4112,9 +4116,13 @@ RequestHeaders::ApplyToChannel(nsIHttpChannel* aHttpChannel) const
{ {
for (const RequestHeader& header : mHeaders) { for (const RequestHeader& header : mHeaders) {
if (header.mValue.IsEmpty()) { if (header.mValue.IsEmpty()) {
aHttpChannel->SetEmptyRequestHeader(header.mName); DebugOnly<nsresult> rv =
aHttpChannel->SetEmptyRequestHeader(header.mName);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} else { } else {
aHttpChannel->SetRequestHeader(header.mName, header.mValue, false); DebugOnly<nsresult> rv =
aHttpChannel->SetRequestHeader(header.mName, header.mValue, false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
} }

View file

@ -427,7 +427,8 @@ XMLDocument::Load(const nsAString& aUrl, CallerType aCallerType,
// when Request.mode set correctly. // when Request.mode set correctly.
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(channel); nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(channel);
if (httpChannel) { if (httpChannel) {
httpChannel->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN); rv = httpChannel->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
// StartDocumentLoad asserts that readyState is uninitialized, so // StartDocumentLoad asserts that readyState is uninitialized, so

View file

@ -308,7 +308,7 @@ txStylesheetSink::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest); nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
if (httpChannel) { if (httpChannel) {
httpChannel->GetRequestSucceeded(&success); Unused << httpChannel->GetRequestSucceeded(&success);
} }
nsresult result = aStatusCode; nsresult result = aStatusCode;
@ -462,14 +462,17 @@ txCompileObserver::startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler,
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) { if (httpChannel) {
httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), DebugOnly<nsresult> rv;
NS_LITERAL_CSTRING("*/*"), rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
false); NS_LITERAL_CSTRING("*/*"),
false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIURI> referrerURI; nsCOMPtr<nsIURI> referrerURI;
aReferrerPrincipal->GetURI(getter_AddRefs(referrerURI)); aReferrerPrincipal->GetURI(getter_AddRefs(referrerURI));
if (referrerURI) { if (referrerURI) {
httpChannel->SetReferrerWithPolicy(referrerURI, aReferrerPolicy); rv = httpChannel->SetReferrerWithPolicy(referrerURI, aReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }