Bug 1523427 - Check whether we really have a response for a upgrade request before making a connection DontReuse. r=michal a=lizzard
authorDragana Damjanovic <dd.mozilla@gmail.com>
Thu, 31 Jan 2019 15:09:01 +0000
changeset 515663 e420e8059fe01b06f4cd77ecf9134036380f443b
parent 515662 25b336aa98ee6dd86d59f12ebc8bce3d11b9a7c7
child 515664 a4da2c3de38fd19c313dd1ab8f8f10e847560012
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal, lizzard
bugs1523427
milestone66.0
Bug 1523427 - Check whether we really have a response for a upgrade request before making a connection DontReuse. r=michal a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D18202
netwerk/protocol/http/nsHttpConnection.cpp
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -1284,16 +1284,17 @@ nsresult nsHttpConnection::OnHeadersAvai
   if (!foundKeepAliveMax && mRemainingConnectionUses &&
       (mUsingSpdyVersion == SpdyVersion::NONE))
     --mRemainingConnectionUses;
 
   // If we're doing a proxy connect, we need to check whether or not
   // it was successful.  If so, we have to reset the transaction and step-up
   // the socket connection if using SSL. Finally, we have to wake up the
   // socket write request.
+  bool itWasProxyConnect = !!mProxyConnectStream;
   if (mProxyConnectStream) {
     MOZ_ASSERT(mUsingSpdyVersion == SpdyVersion::NONE,
                "SPDY NPN Complete while using proxy connect stream");
     mProxyConnectStream = nullptr;
     bool isHttps = mTransaction ? mTransaction->ConnectionInfo()->EndToEndSSL()
                                 : mConnInfo->EndToEndSSL();
     bool onlyConnect = mTransactionCaps & NS_HTTP_CONNECT_ONLY;
 
@@ -1342,18 +1343,18 @@ nsresult nsHttpConnection::OnHeadersAvai
 
   nsAutoCString upgradeReq;
   bool hasUpgradeReq =
       NS_SUCCEEDED(requestHead->GetHeader(nsHttp::Upgrade, upgradeReq));
   // Don't use persistent connection for Upgrade unless there's an auth failure:
   // some proxies expect to see auth response on persistent connection.
   // Also allow persistent conn for h2, as we don't want to waste connections
   // for multiplexed upgrades.
-  if (hasUpgradeReq && responseStatus != 401 && responseStatus != 407 &&
-      !mSpdySession) {
+  if (!itWasProxyConnect && hasUpgradeReq && responseStatus != 401 &&
+      responseStatus != 407 && !mSpdySession) {
     LOG(("HTTP Upgrade in play - disable keepalive for http/1.x\n"));
     DontReuse();
   }
 
   if (responseStatus == 101) {
     nsAutoCString upgradeResp;
     bool hasUpgradeResp =
         NS_SUCCEEDED(responseHead->GetHeader(nsHttp::Upgrade, upgradeResp));