Bug 767506 - Select proper proxy caps for non-SSL CONNECT. r=honzab

This commit is contained in:
Jason Duell 2012-07-02 17:38:34 -07:00
Родитель 7d1d6d78b3
Коммит 7d56fc2f60
3 изменённых файлов: 41 добавлений и 14 удалений

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

@ -75,6 +75,7 @@
#include "nsIRedirectChannelRegistrar.h"
#include "nsIMIMEHeaderParam.h"
#include "mozilla/Services.h"
#include "nsCRT.h"
#ifdef MOZILLA_INTERNAL_API
@ -714,6 +715,37 @@ NS_NewProxyInfo(const nsACString &type,
return rv;
}
// returns 'true' if this is an HTTP proxy. If 'usingConnect' passed, sets it
// to true if proxy is HTTP and is using CONNECT tunnel, else sets it to false
inline bool
NS_IsHttpProxy(nsIProxyInfo *proxyInfo, bool usingSSL, bool *usingConnect)
{
if (usingConnect)
*usingConnect = false;
if (!proxyInfo)
return false;
nsCString proxyType;
nsresult rv = proxyInfo->GetType(proxyType);
if (NS_FAILED(rv))
return false;
bool isHttp = !nsCRT::strcmp(proxyType.get(), "http");
// Only HTTP proxies use CONNECT
if (isHttp && usingConnect) {
*usingConnect = usingSSL; // SSL always uses CONNECT w/HTTP proxy
if (!usingConnect) {
PRUint32 resolveFlags = 0;
if (NS_SUCCEEDED(proxyInfo->GetResolveFlags(&resolveFlags)) &&
resolveFlags & nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL) {
*usingConnect = true;
}
}
}
return isHttp;
}
inline nsresult
NS_GetFileProtocolHandler(nsIFileProtocolHandler **result,
nsIIOService *ioService = nsnull)

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

@ -7,6 +7,7 @@
#define nsHttpConnectionInfo_h__
#include "nsHttp.h"
#include "nsNetUtil.h"
#include "nsProxyInfo.h"
#include "nsCOMPtr.h"
#include "nsDependentString.h"
@ -32,20 +33,11 @@ public:
{
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;
}
}
mUsingHttpProxy = NS_IsHttpProxy(proxyInfo, usingSSL, &mUsingConnect);
SetOriginServer(host, port);
}
~nsHttpConnectionInfo()
{
LOG(("Destroying nsHttpConnectionInfo @%x\n", this));

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

@ -1428,13 +1428,16 @@ nsHttpHandler::NewProxiedChannel(nsIURI *uri,
httpChannel = new nsHttpChannel();
}
// select proxy caps if using a non-transparent proxy. SSL tunneling
// select proxy caps if using a non-transparent proxy. CONNECT tunneling
// should not use proxy settings.
PRInt8 caps;
if (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http") && !https)
bool usingConnect;
bool usingHttpProxy = NS_IsHttpProxy(proxyInfo, https, &usingConnect);
if (usingHttpProxy && !usingConnect) {
caps = mProxyCapabilities;
else
} else {
caps = mCapabilities;
}
if (https) {
// enable pipelining over SSL if requested