bug 795905 call proxyservice::asyncresolve() when direct in case of filters r=biesi
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 04 Oct 2012 15:08:26 -0400
changeset 115574 0fdefdb3481df9214851338cfc6c47ca9fa635d9
parent 115573 66b4f2ea351d297c57e424ba6c5dfc03f19807d2
child 115575 a2630fb2dbfa056a44106b59c84bfc7f9351a943
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersbiesi
bugs795905
milestone18.0a1
bug 795905 call proxyservice::asyncresolve() when direct in case of filters r=biesi
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/test/unit/test_protocolproxyservice.js
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -1763,23 +1763,20 @@ nsFtpState::Init(nsFtpChannel *channel)
     if (NS_FAILED(rv))
         return rv;
 
     if (port > 0)
         mPort = port;
 
     // Lookup Proxy information asynchronously if it isn't already set
     // on the channel and if we aren't configured explicitly to go directly
-    uint32_t proxyConfigType;
     nsCOMPtr<nsIProtocolProxyService> pps =
         do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID);
 
-    if (pps && !mChannel->ProxyInfo() &&
-        NS_SUCCEEDED(pps->GetProxyConfigType(&proxyConfigType)) &&
-        proxyConfigType != nsIProtocolProxyService::PROXYCONFIG_DIRECT) {
+    if (pps && !mChannel->ProxyInfo()) {
         pps->AsyncResolve(mChannel->URI(), 0, this,
                           getter_AddRefs(mProxyRequest));
     }
 
     return NS_OK;
 }
 
 void
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1722,24 +1722,16 @@ nsHttpChannel::ResolveProxy()
 
     nsresult rv;
 
     nsCOMPtr<nsIProtocolProxyService> pps =
             do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
     if (NS_FAILED(rv))
         return rv;
 
-    // Check if we are configured to directly connect. This will save us
-    // a round trip through the event dispatch system
-    uint32_t proxyConfigType;
-    if (NS_SUCCEEDED(pps->GetProxyConfigType(&proxyConfigType)) &&
-        proxyConfigType == nsIProtocolProxyService::PROXYCONFIG_DIRECT) {
-        return NS_ERROR_FAILURE;
-    }
-
     return pps->AsyncResolve(mProxyURI ? mProxyURI : mURI, mProxyResolveFlags,
                              this, getter_AddRefs(mProxyRequest));
 }
 
 bool
 HttpCacheQuery::ResponseWouldVary() const
 {
     AssertOnCacheThread();
--- a/netwerk/test/unit/test_protocolproxyservice.js
+++ b/netwerk/test/unit/test_protocolproxyservice.js
@@ -611,25 +611,44 @@ function run_failed_script_test()
   prefs.setIntPref("network.proxy.type", 2);
   prefs.setCharPref("network.proxy.autoconfig_url", pac);
 
   var cb = new resolveCallback();
   cb.nextFunction = failed_script_callback;
   var req = pps.asyncResolve(uri, 0, cb);
 }
 
+var directFilter;
+
 function failed_script_callback(pi)
 {
   // we should go direct
   do_check_eq(pi, null);
 
+  // test that we honor filters when configured to go direct
   prefs.setIntPref("network.proxy.type", 0);
-  do_test_finished();
+  directFilter = new TestFilter("http", "127.0.0.1", 7246, 0, 0);
+  pps.registerFilter(directFilter, 10);
+
+  var chan = ios.newChannel("http://127.0.0.1:7247", "", null);
+  chan.asyncOpen(directFilterListener, chan);
 }
 
+var directFilterListener = {
+  onStartRequest: function test_onStart(request, ctx) {  },
+  onDataAvailable: function test_OnData() { },
+
+  onStopRequest: function test_onStop(request, ctx, status) {
+    ctx.QueryInterface(Components.interfaces.nsIProxiedChannel);
+    check_proxy(ctx.proxyInfo, "http", "127.0.0.1", 7246, 0, 0, false);
+    pps.unregisterFilter(directFilter);
+    do_test_finished();
+  },
+};
+
 function run_deprecated_sync_test()
 {
   var uri = ios.newURI("http://www.mozilla.org/", null, null);
 
   pps.QueryInterface(Components.interfaces.nsIProtocolProxyService2);
 
   // Verify initial state
   var pi = pps.deprecatedBlockingResolve(uri, 0);