Bug 1310127 - Part 16: Use MOZ_MUST_USE in netwerk/protocol/http r?smaug
MozReview-Commit-ID: Ihow5ushWou
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -534,18 +534,18 @@ nsresult nsDocumentOpenInfo::DispatchCon
}
// Before dispatching to the external helper app service, check for an HTTP
// error page. If we got one, we don't want to handle it with a helper app,
// really.
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
if (httpChannel) {
bool requestSucceeded;
- httpChannel->GetRequestSucceeded(&requestSucceeded);
- if (!requestSucceeded) {
+ rv = httpChannel->GetRequestSucceeded(&requestSucceeded);
+ if (NS_FAILED(rv) || !requestSucceeded) {
// returning error from OnStartRequest will cancel the channel
return NS_ERROR_FILE_NOT_FOUND;
}
}
// Sixth step:
//
// All attempts to dispatch this content have failed. Just pass it off to
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -787,17 +787,17 @@ NS_IMETHODIMP nsExternalHelperAppService
channel->GetContentDispositionFilename(fileName);
// Check if we have a POST request, in which case we don't want to use
// the url's extension
bool allowURLExt = true;
nsCOMPtr<nsIHttpChannel> httpChan = do_QueryInterface(channel);
if (httpChan) {
nsAutoCString requestMethod;
- httpChan->GetRequestMethod(requestMethod);
+ Unused << httpChan->GetRequestMethod(requestMethod);
allowURLExt = !requestMethod.EqualsLiteral("POST");
}
// Check if we had a query string - we don't want to check the URL
// extension if a query is present in the URI
// If we already know we don't want to check the URL extension, don't
// bother checking the query
if (uri && allowURLExt) {
@@ -1669,18 +1669,18 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt
// retarget all load notifications to our docloader instead of the original window's docloader...
RetargetLoadNotifications(request);
// Check to see if there is a refresh header on the original channel.
if (mOriginalChannel) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mOriginalChannel));
if (httpChannel) {
nsAutoCString refreshHeader;
- httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("refresh"),
- refreshHeader);
+ Unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("refresh"),
+ refreshHeader);
if (!refreshHeader.IsEmpty()) {
mShouldCloseWindow = false;
}
}
}
// Close the underlying DOMWindow if there is no refresh header
// and it was opened specifically for the download
@@ -1720,17 +1720,18 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt
SendStatusChange(kWriteError, transferError, request, path);
return NS_OK;
}
// Inform channel it is open on behalf of a download to prevent caching.
nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(aChannel);
if (httpInternal) {
- httpInternal->SetChannelIsForDownload(true);
+ rv = httpInternal->SetChannelIsForDownload(true);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
}
// now that the temp file is set up, find out if we need to invoke a dialog
// asking the user what they want us to do with this content...
// We can get here for three reasons: "can't handle", "sniffed type", or
// "server sent content-disposition:attachment". In the first case we want
// to honor the user's "always ask" pref; in the other two cases we want to
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -187,20 +187,22 @@ nsManifestCheck::Begin()
nsIRequest::LOAD_BYPASS_CACHE);
NS_ENSURE_SUCCESS(rv, rv);
// configure HTTP specific stuff
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(mChannel);
if (httpChannel) {
- httpChannel->SetReferrer(mReferrerURI);
- httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
- NS_LITERAL_CSTRING("offline-resource"),
- false);
+ rv = httpChannel->SetReferrer(mReferrerURI);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+ NS_LITERAL_CSTRING("offline-resource"),
+ false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
}
return mChannel->AsyncOpen2(this);
}
//-----------------------------------------------------------------------------
// nsManifestCheck <public>
//-----------------------------------------------------------------------------
@@ -396,20 +398,22 @@ nsOfflineCacheUpdateItem::OpenChannel(ns
// Set the new application cache as the target for write.
rv = appCacheChannel->SetApplicationCacheForWrite(mApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
// configure HTTP specific stuff
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(mChannel);
if (httpChannel) {
- httpChannel->SetReferrer(mReferrerURI);
- httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
- NS_LITERAL_CSTRING("offline-resource"),
- false);
+ rv = httpChannel->SetReferrer(mReferrerURI);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+ NS_LITERAL_CSTRING("offline-resource"),
+ false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
}
rv = mChannel->AsyncOpen2(this);
NS_ENSURE_SUCCESS(rv, rv);
mUpdate = aUpdate;
mState = LoadStatus::REQUESTED;
@@ -574,19 +578,20 @@ nsOfflineCacheUpdateItem::AsyncOnChannel
LOG(("rejected: redirected to a different scheme\n"));
return NS_ERROR_ABORT;
}
// HTTP request headers are not automatically forwarded to the new channel.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aNewChannel);
NS_ENSURE_STATE(httpChannel);
- httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
- NS_LITERAL_CSTRING("offline-resource"),
- false);
+ rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+ NS_LITERAL_CSTRING("offline-resource"),
+ false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
mChannel = aNewChannel;
cb->OnRedirectVerifyCallback(NS_OK);
return NS_OK;
}
nsresult
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -145,21 +145,22 @@ nsPrefetchNode::OpenChannel()
nsICachingChannel::LOAD_ONLY_IF_MODIFIED);
NS_ENSURE_SUCCESS(rv, rv);
// configure HTTP specific stuff
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(mChannel);
if (httpChannel) {
- httpChannel->SetReferrerWithPolicy(mReferrerURI, referrerPolicy);
- httpChannel->SetRequestHeader(
- NS_LITERAL_CSTRING("X-Moz"),
- NS_LITERAL_CSTRING("prefetch"),
- false);
+ rv = httpChannel->SetReferrerWithPolicy(mReferrerURI, referrerPolicy);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+ NS_LITERAL_CSTRING("prefetch"),
+ false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
}
// Reduce the priority of prefetch network requests.
nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(mChannel);
if (priorityChannel) {
priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
}
@@ -334,19 +335,20 @@ nsPrefetchNode::AsyncOnChannelRedirect(n
return NS_ERROR_ABORT;
}
}
// HTTP request headers are not automatically forwarded to the new channel.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aNewChannel);
NS_ENSURE_STATE(httpChannel);
- httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
- NS_LITERAL_CSTRING("prefetch"),
- false);
+ rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+ NS_LITERAL_CSTRING("prefetch"),
+ false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
// Assign to mChannel after we get notification about success of the
// redirect in OnRedirectResult.
mRedirectChannel = aNewChannel;
callback->OnRedirectVerifyCallback(NS_OK);
return NS_OK;
}