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
Родитель 29f4cc8d4a
Коммит 510ba75c20
22 изменённых файлов: 144 добавлений и 85 удалений

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

@ -995,18 +995,22 @@ EventSourceImpl::SetupHttpChannel()
{
AssertIsOnMainThread();
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 */
mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
NS_LITERAL_CSTRING(TEXT_EVENT_STREAM), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
// LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header
if (!mLastEventID.IsEmpty()) {
mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"),
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"),
NS_ConvertUTF16toUTF8(mLastEventID), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}

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

@ -1349,7 +1349,8 @@ Navigator::SendBeaconInternal(const nsAString& aUrl,
aRv.Throw(NS_ERROR_DOM_BAD_URI);
return false;
}
httpChannel->SetReferrer(documentURI);
rv = httpChannel->SetReferrer(documentURI);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIInputStream> in;
nsAutoCString contentTypeWithCharset;
@ -1379,7 +1380,8 @@ Navigator::SendBeaconInternal(const nsAString& aUrl,
NS_LITERAL_CSTRING("POST"),
false);
} 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);

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -355,7 +355,10 @@ InternalHeaders::FillResponseHeaders(nsIRequest* aRequest)
}
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

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

@ -291,7 +291,9 @@ HttpServer::TransportProvider::MaybeNotify()
RefPtr<TransportProvider> 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);
}

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

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

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

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

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

@ -154,7 +154,8 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel,
new PerformanceResourceTiming(performanceTiming, this, entryName);
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.
nsCOMPtr<nsICacheInfoChannel> cachedChannel = do_QueryInterface(channel);
@ -169,15 +170,15 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel,
performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol));
uint64_t encodedBodySize = 0;
channel->GetEncodedBodySize(&encodedBodySize);
Unused << channel->GetEncodedBodySize(&encodedBodySize);
performanceEntry->SetEncodedBodySize(encodedBodySize);
uint64_t transferSize = 0;
channel->GetTransferSize(&transferSize);
Unused << channel->GetTransferSize(&transferSize);
performanceEntry->SetTransferSize(transferSize);
uint64_t decodedBodySize = 0;
channel->GetDecodedBodySize(&decodedBodySize);
Unused << channel->GetDecodedBodySize(&decodedBodySize);
if (decodedBodySize == 0) {
decodedBodySize = encodedBodySize;
}

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

@ -777,7 +777,8 @@ nsPluginStreamListenerPeer::RequestRead(NPByteRange* rangeList)
if (!httpChannel)
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
// the request on the next ODA.
@ -1174,7 +1175,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
}
// Also provide all HTTP response headers to our listener.
httpChannel->VisitResponseHeaders(this);
rv = httpChannel->VisitResponseHeaders(this);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mSeekable = false;
// first we look for a content-encoding header. If we find one, we tell the

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

@ -1000,7 +1000,8 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
// if this is an HTTP channel, set the request method to post
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(reportChannel));
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();

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

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

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

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

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

@ -1384,7 +1384,8 @@ public:
nsAutoCString referrer;
// 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()) {
mReferrer = referrer;
} else {
@ -1439,15 +1440,18 @@ public:
// This is safe due to static_asserts in ServiceWorkerManager.cpp.
uint32_t redirectMode;
internalChannel->GetRedirectMode(&redirectMode);
rv = internalChannel->GetRedirectMode(&redirectMode);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mRequestRedirect = static_cast<RequestRedirect>(redirectMode);
// This is safe due to static_asserts in ServiceWorkerManager.cpp.
uint32_t cacheMode;
internalChannel->GetFetchCacheMode(&cacheMode);
rv = internalChannel->GetFetchCacheMode(&cacheMode);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mCacheMode = static_cast<RequestCache>(cacheMode);
internalChannel->GetIntegrityMetadata(mIntegrity);
rv = internalChannel->GetIntegrityMetadata(mIntegrity);
MOZ_ASSERT(NS_SUCCEEDED(rv));
mRequestCredentials = InternalRequest::MapChannelToRequestCredentials(channel);

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

@ -671,11 +671,13 @@ CompareNetwork::Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsIL
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (httpChannel) {
// 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"),
NS_LITERAL_CSTRING("script"),
/* merge */ false);
rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Service-Worker"),
NS_LITERAL_CSTRING("script"),
/* merge */ false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
nsCOMPtr<nsIStreamLoader> loader;
@ -765,7 +767,7 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext
// Get the stringified numeric status code, not statusText which could be
// something misleading like OK for a 404.
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;
statusAsText.AppendInt(status);

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

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

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

@ -427,7 +427,8 @@ XMLDocument::Load(const nsAString& aUrl, CallerType aCallerType,
// when Request.mode set correctly.
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(channel);
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

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

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