Bug 1449259: Don't do proxy lookups for loads that are only going to come from the cache. r?mayhemer draft
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 04 Apr 2018 16:17:25 -0700
changeset 778026 9407f3ffd968a3dcb2ee62e688db1f5158981bb4
parent 777514 cadd4b3c2bcb0ea8a0a82f37df184224ac16efc7
push id105368
push userdtownsend@mozilla.com
push dateThu, 05 Apr 2018 18:13:44 +0000
reviewersmayhemer
bugs1449259
milestone61.0a1
Bug 1449259: Don't do proxy lookups for loads that are only going to come from the cache. r?mayhemer MozReview-Commit-ID: GI9t8HWesZY
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6063,18 +6063,20 @@ nsHttpChannel::AsyncOpen(nsIStreamListen
     mAsyncOpenTime = TimeStamp::Now();
 
     // Remember we have Authorization header set here.  We need to check on it
     // just once and early, AsyncOpen is the best place.
     mCustomAuthHeader = mRequestHead.HasHeader(nsHttp::Authorization);
 
     // The common case for HTTP channels is to begin proxy resolution and return
     // at this point. The only time we know mProxyInfo already is if we're
-    // proxying a non-http protocol like ftp.
-    if (!mProxyInfo && NS_SUCCEEDED(ResolveProxy())) {
+    // proxying a non-http protocol like ftp. We don't need to discover proxy
+    // settings if we are never going to make a network connection.
+    if (!mProxyInfo && !(mLoadFlags & (LOAD_ONLY_FROM_CACHE | LOAD_NO_NETWORK_IO)) &&
+        NS_SUCCEEDED(ResolveProxy())) {
         return NS_OK;
     }
 
     rv = BeginConnect();
     if (NS_FAILED(rv)) {
         CloseCacheEntry(false);
         Unused << AsyncAbort(rv);
     }