diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 3fd20b356a8..b9d495e8d3f 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -130,7 +130,7 @@ HttpBaseChannel::Init(nsIURI *aURI, rv = gHttpHandler-> AddStandardRequestHeaders(&mRequestHead.Headers(), aCaps, - !mConnectionInfo->UsingSSL() && + !mConnectionInfo->UsingConnect() && mConnectionInfo->UsingHttpProxy()); return rv; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index e319b0afcb5..895cc0c4308 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -713,8 +713,7 @@ nsHttpChannel::SetupTransaction() // does not count here). also, figure out what version we should be speaking. nsCAutoString buf, path; nsCString* requestURI; - if (mConnectionInfo->UsingSSL() || - mConnectionInfo->ShouldForceConnectMethod() || + if (mConnectionInfo->UsingConnect() || !mConnectionInfo->UsingHttpProxy()) { rv = mURI->GetPath(path); if (NS_FAILED(rv)) return rv; @@ -4634,9 +4633,7 @@ nsHttpChannel::GetIsSSL(bool *aIsSSL) NS_IMETHODIMP nsHttpChannel::GetProxyMethodIsConnect(bool *aProxyMethodIsConnect) { - *aProxyMethodIsConnect = - (mConnectionInfo->UsingHttpProxy() && mConnectionInfo->UsingSSL()) || - mConnectionInfo->ShouldForceConnectMethod(); + *aProxyMethodIsConnect = mConnectionInfo->UsingConnect(); return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index eaf85703939..a83cf9ed2be 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -349,8 +349,7 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps, PRInt32 pri) // need to handle HTTP CONNECT tunnels if this is the first time if // we are tunneling through a proxy - if (((mConnInfo->UsingSSL() && mConnInfo->UsingHttpProxy()) || - mConnInfo->ShouldForceConnectMethod()) && !mCompletedProxyConnect) { + if (mConnInfo->UsingConnect() && !mCompletedProxyConnect) { rv = SetupProxyConnect(); if (NS_FAILED(rv)) goto failed_activation; @@ -637,7 +636,7 @@ nsHttpConnection::SupportsPipelining(nsHttpResponseHead *responseHead) return false; // assuming connection is HTTP/1.1 with keep-alive enabled - if (mConnInfo->UsingHttpProxy() && !mConnInfo->UsingSSL()) { + if (mConnInfo->UsingHttpProxy() && !mConnInfo->UsingConnect()) { // XXX check for bad proxy servers... return true; } diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp index 8a179b61b33..a797088e551 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp +++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsHttpConnectionInfo.h" -#include "nsIProtocolProxyService.h" void nsHttpConnectionInfo::SetOriginServer(const nsACString &host, PRInt32 port) @@ -25,7 +24,7 @@ nsHttpConnectionInfo::SetOriginServer(const nsACString &host, PRInt32 port) const char *keyHost; PRInt32 keyPort; - if (mUsingHttpProxy && !mUsingSSL) { + if (mUsingHttpProxy && !mUsingConnect) { keyHost = ProxyHost(); keyPort = ProxyPort(); } @@ -66,18 +65,3 @@ nsHttpConnectionInfo::Clone() const return clone; } -bool -nsHttpConnectionInfo::ShouldForceConnectMethod() -{ - if (!mProxyInfo) - return false; - - PRUint32 resolveFlags; - nsresult rv; - - rv = mProxyInfo->GetResolveFlags(&resolveFlags); - if (NS_FAILED(rv)) - return false; - - return resolveFlags & nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL; -} diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.h b/netwerk/protocol/http/nsHttpConnectionInfo.h index cbbb3239c61..8b097e271e7 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.h +++ b/netwerk/protocol/http/nsHttpConnectionInfo.h @@ -13,6 +13,7 @@ #include "nsString.h" #include "plstr.h" #include "nsCRT.h" +#include "nsIProtocolProxyService.h" //----------------------------------------------------------------------------- // nsHttpConnectionInfo - holds the properties of a connection @@ -27,11 +28,21 @@ public: : mRef(0) , mProxyInfo(proxyInfo) , mUsingSSL(usingSSL) + , mUsingConnect(false) { LOG(("Creating nsHttpConnectionInfo @%x\n", this)); mUsingHttpProxy = (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http")); + if (mUsingHttpProxy) { + mUsingConnect = mUsingSSL; // SSL always uses CONNECT + PRUint32 resolveFlags = 0; + if (NS_SUCCEEDED(mProxyInfo->GetResolveFlags(&resolveFlags)) && + resolveFlags & nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL) { + mUsingConnect = true; + } + } + SetOriginServer(host, port); } @@ -89,6 +100,7 @@ public: nsProxyInfo *ProxyInfo() { return mProxyInfo; } bool UsingHttpProxy() const { return mUsingHttpProxy; } bool UsingSSL() const { return mUsingSSL; } + bool UsingConnect() const { return mUsingConnect; } PRInt32 DefaultPort() const { return mUsingSSL ? NS_HTTPS_DEFAULT_PORT : NS_HTTP_DEFAULT_PORT; } void SetAnonymous(bool anon) { mHashKey.SetCharAt(anon ? 'A' : '.', 2); } @@ -96,7 +108,6 @@ public: void SetPrivate(bool priv) { mHashKey.SetCharAt(priv ? 'P' : '.', 3); } bool GetPrivate() const { return mHashKey.CharAt(3) == 'P'; } - bool ShouldForceConnectMethod(); const nsCString &GetHost() { return mHost; } private: @@ -107,6 +118,7 @@ private: nsCOMPtr mProxyInfo; bool mUsingHttpProxy; bool mUsingSSL; + bool mUsingConnect; // if will use CONNECT with http proxy }; #endif // nsHttpConnectionInfo_h__ diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 60a6807ac05..c299c2be532 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -1144,7 +1144,7 @@ nsHttpConnectionMgr::AtActiveConnectionLimit(nsConnectionEntry *ent, PRUint8 cap PRUint16 maxConns; PRUint16 maxPersistConns; - if (ci->UsingHttpProxy() && !ci->UsingSSL()) { + if (ci->UsingHttpProxy() && !ci->UsingConnect()) { maxConns = mMaxConnsPerProxy; maxPersistConns = mMaxPersistConnsPerProxy; } diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 5c9c9bd8b35..280937e954a 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -236,10 +236,8 @@ nsHttpTransaction::Init(PRUint8 caps, mRequestHead = requestHead; // make sure we eliminate any proxy specific headers from - // the request if we are talking HTTPS via a SSL tunnel. - bool pruneProxyHeaders = - cinfo->ShouldForceConnectMethod() || - (cinfo->UsingSSL() && cinfo->UsingHttpProxy()); + // the request if we are using CONNECT + bool pruneProxyHeaders = cinfo->UsingConnect(); mReqHeaderBuf.Truncate(); requestHead->Flatten(mReqHeaderBuf, pruneProxyHeaders);