Bug 713026 - websockets bootstrap via proxy should always CONNECT. r=mcmanus

This commit is contained in:
Jason Duell 2012-06-18 22:50:20 -07:00
Родитель bad59c0278
Коммит 0a66a023f2
7 изменённых файлов: 22 добавлений и 32 удалений

Просмотреть файл

@ -130,7 +130,7 @@ HttpBaseChannel::Init(nsIURI *aURI,
rv = gHttpHandler->
AddStandardRequestHeaders(&mRequestHead.Headers(), aCaps,
!mConnectionInfo->UsingSSL() &&
!mConnectionInfo->UsingConnect() &&
mConnectionInfo->UsingHttpProxy());
return rv;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsProxyInfo> mProxyInfo;
bool mUsingHttpProxy;
bool mUsingSSL;
bool mUsingConnect; // if will use CONNECT with http proxy
};
#endif // nsHttpConnectionInfo_h__

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);