diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index fe77dc554ea..65593f227ad 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -391,13 +391,17 @@ pref("network.hosts.smtp_server", "mail"); pref("network.hosts.pop_server", "mail"); pref("network.protocols.useSystemDefaults", false); // set to true if user links should use system default handlers -// +// pref("network.http.version", "1.1"); // default // pref("network.http.version", "1.0"); // uncomment this out in case of problems // pref("network.http.version", "0.9"); // it'll work too if you're crazy // keep-alive option is effectively obsolete. Nevertheless it'll work with // some older 1.0 servers: +pref("network.http.proxy.version", "1.1"); // default +// pref("network.http.proxy.version", "1.0"); // uncomment this out in case of problems + // (required if using junkbuster proxy) + // enable caching of http documents pref("network.http.use-cache", true); @@ -458,7 +462,7 @@ pref("network.http.pipelining.firstrequest", false); pref("network.http.pipelining.maxrequests" , 4); pref("network.http.proxy.ssl.connect",true); -// +// // This preference controls whether or not internationalized domain names (IDN) // are handled. IDN requires a nsIIDNService implementation. diff --git a/mozilla/netwerk/protocol/http/src/nsAHttpConnection.h b/mozilla/netwerk/protocol/http/src/nsAHttpConnection.h index e1b94fdeca8..4ed0d40af24 100644 --- a/mozilla/netwerk/protocol/http/src/nsAHttpConnection.h +++ b/mozilla/netwerk/protocol/http/src/nsAHttpConnection.h @@ -4,6 +4,7 @@ #include "nsISupports.h" class nsAHttpTransaction; +class nsHttpRequestHead; class nsHttpResponseHead; class nsHttpConnectionInfo; @@ -18,6 +19,7 @@ public: // the connection can force the transaction to reset it's response headers, // and prepare for a new set of response headers, by setting |*reset=TRUE|. virtual nsresult OnHeadersAvailable(nsAHttpTransaction *, + nsHttpRequestHead *, nsHttpResponseHead *, PRBool *reset) = 0; diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index 053eabaad97..acc8416351a 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -180,8 +180,8 @@ nsHttpChannel::Init(nsIURI *uri, if (NS_FAILED(rv)) return rv; rv = nsHttpHandler::get()-> - AddStandardRequestHeaders(&mRequestHead.Headers(), - caps, + AddStandardRequestHeaders(&mRequestHead.Headers(), caps, + !mConnectionInfo->UsingSSL() && mConnectionInfo->UsingHttpProxy()); if (NS_FAILED(rv)) return rv; @@ -385,7 +385,7 @@ nsHttpChannel::SetupTransaction() NS_ADDREF(mTransaction); // use the URI path if not proxying (transparent proxying such as SSL proxy - // does not count here). + // does not count here). also, figure out what version we should be speaking. nsCAutoString buf, path; const char* requestURI; if (mConnectionInfo->UsingSSL() || !mConnectionInfo->UsingHttpProxy()) { @@ -396,15 +396,17 @@ nsHttpChannel::SetupTransaction() requestURI = buf.get(); else requestURI = path.get(); + mRequestHead.SetVersion(nsHttpHandler::get()->HttpVersion()); } - else + else { requestURI = mSpec.get(); + mRequestHead.SetVersion(nsHttpHandler::get()->ProxyHttpVersion()); + } // trim off the #ref portion if any... char *p = (char *)strchr(requestURI, '#'); if (p) *p = 0; - mRequestHead.SetVersion(nsHttpHandler::get()->DefaultVersion()); mRequestHead.SetRequestURI(requestURI); // set the request time for cache expiration calculations @@ -435,7 +437,8 @@ nsHttpChannel::SetupTransaction() return mTransaction->SetupRequest(&mRequestHead, mUploadStream, mUploadStreamHasHeaders, - mConnectionInfo->UsingHttpProxy() && mConnectionInfo->UsingSSL()); + mConnectionInfo->UsingSSL() && + mConnectionInfo->UsingHttpProxy()); } void diff --git a/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp b/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp index 2fe6923f735..285dbd7330b 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp @@ -163,6 +163,7 @@ nsHttpConnection::IsAlive() // called from the socket thread nsresult nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans, + nsHttpRequestHead *requestHead, nsHttpResponseHead *responseHead, PRBool *reset) { @@ -186,7 +187,7 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans, val = responseHead->PeekHeader(nsHttp::Proxy_Connection); if ((responseHead->Version() < NS_HTTP_VERSION_1_1) || - (nsHttpHandler::get()->DefaultVersion() < NS_HTTP_VERSION_1_1)) { + (requestHead->Version() < NS_HTTP_VERSION_1_1)) { // HTTP/1.0 connections are by default NOT persistent if (val && !PL_strcasecmp(val, "keep-alive")) mKeepAlive = PR_TRUE; @@ -490,7 +491,7 @@ nsHttpConnection::SetupSSLProxyConnect() // CONNECT host:port HTTP/1.1 nsHttpRequestHead request; request.SetMethod(nsHttp::Connect); - request.SetVersion(nsHttpHandler::get()->DefaultVersion()); + request.SetVersion(nsHttpHandler::get()->HttpVersion()); request.SetRequestURI(buf.get()); request.SetHeader(nsHttp::User_Agent, nsHttpHandler::get()->UserAgent()); diff --git a/mozilla/netwerk/protocol/http/src/nsHttpConnection.h b/mozilla/netwerk/protocol/http/src/nsHttpConnection.h index 2836109f791..d66f0f21b56 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpConnection.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpConnection.h @@ -87,7 +87,7 @@ public: nsHttpConnectionInfo *ConnectionInfo() { return mConnectionInfo; } // nsAHttpConnection methods: - nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpResponseHead *, PRBool *reset); + nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpRequestHead *, nsHttpResponseHead *, PRBool *reset); nsresult OnTransactionComplete(nsAHttpTransaction *, nsresult status); nsresult OnSuspend(); nsresult OnResume(); diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp index 746f8234368..771d57b3aef 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -100,9 +100,10 @@ nsHttpHandler *nsHttpHandler::mGlobalInstance = 0; nsHttpHandler::nsHttpHandler() : mAuthCache(nsnull) , mHttpVersion(NS_HTTP_VERSION_1_1) - , mReferrerLevel(0xff) // by default we always send a referrer + , mProxyHttpVersion(NS_HTTP_VERSION_1_1) , mCapabilities(NS_HTTP_ALLOW_KEEPALIVE) , mProxyCapabilities(NS_HTTP_ALLOW_KEEPALIVE) + , mReferrerLevel(0xff) // by default we always send a referrer , mIdleTimeout(10) , mMaxRequestAttempts(10) , mMaxRequestDelay(10) @@ -1283,7 +1284,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) if (PREF_CHANGED(HTTP_PREF("version"))) { nsXPIDLCString httpVersion; prefs->GetCharPref(HTTP_PREF("version"), getter_Copies(httpVersion)); - if (httpVersion) { if (!PL_strcmp(httpVersion, "1.1")) mHttpVersion = NS_HTTP_VERSION_1_1; @@ -1292,14 +1292,17 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) else mHttpVersion = NS_HTTP_VERSION_1_0; } + } - if (mHttpVersion == NS_HTTP_VERSION_1_1) { - mCapabilities = NS_HTTP_ALLOW_KEEPALIVE; - mProxyCapabilities = NS_HTTP_ALLOW_KEEPALIVE; - } - else { - mCapabilities = 0; - mProxyCapabilities = 0; + if (PREF_CHANGED(HTTP_PREF("proxy.version"))) { + nsXPIDLCString httpVersion; + prefs->GetCharPref(HTTP_PREF("proxy.version"), getter_Copies(httpVersion)); + if (httpVersion) { + if (!PL_strcmp(httpVersion, "1.1")) + mProxyHttpVersion = NS_HTTP_VERSION_1_1; + else + mProxyHttpVersion = NS_HTTP_VERSION_1_0; + // it does not make sense to issue a HTTP/0.9 request to a proxy server } } @@ -1754,10 +1757,7 @@ nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result) } } - rv = NewProxiedChannel(uri, - nsnull, - result); - return rv; + return NewProxiedChannel(uri, nsnull, result); } NS_IMETHODIMP @@ -1787,16 +1787,28 @@ nsHttpHandler::NewProxiedChannel(nsIURI *uri, return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(httpChannel); - nsresult rv = httpChannel->Init(uri, - mCapabilities, - proxyInfo); + nsresult rv; - if (NS_SUCCEEDED(rv)) - rv = httpChannel-> - QueryInterface(NS_GET_IID(nsIChannel), (void **) result); + // select proxy caps if using a non-transparent proxy + PRInt8 caps = mCapabilities; + if (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http")) { + // SSL tunneling should not use proxy settings + PRBool isHTTPS; + rv = uri->SchemeIs("https", &isHTTPS); + if (NS_FAILED(rv)) return rv; + if (!isHTTPS) + caps = mProxyCapabilities; + } - NS_RELEASE(httpChannel); - return rv; + rv = httpChannel->Init(uri, caps, proxyInfo); + + if (NS_FAILED(rv)) { + NS_RELEASE(httpChannel); + return rv; + } + + *result = httpChannel; + return NS_OK; } //----------------------------------------------------------------------------- diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.h b/mozilla/netwerk/protocol/http/src/nsHttpHandler.h index 3129226ee07..1584d920d19 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.h @@ -85,7 +85,8 @@ public: const nsAFlatCString &UserAgent(); - nsHttpVersion DefaultVersion() { return mHttpVersion; } + nsHttpVersion HttpVersion() { return mHttpVersion; } + nsHttpVersion ProxyHttpVersion() { return mProxyHttpVersion; } PRUint8 ReferrerLevel() { return mReferrerLevel; } PRBool SendSecureXSiteReferrer() { return mSendSecureXSiteReferrer; } PRUint8 RedirectionLimit() { return mRedirectionLimit; } @@ -219,9 +220,10 @@ private: // PRUint8 mHttpVersion; - PRUint8 mReferrerLevel; + PRUint8 mProxyHttpVersion; PRUint8 mCapabilities; PRUint8 mProxyCapabilities; + PRUint8 mReferrerLevel; PRUint16 mIdleTimeout; PRUint16 mMaxRequestAttempts; diff --git a/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp b/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp index 66c14a2a98b..f6bab65efd0 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp @@ -499,7 +499,7 @@ nsHttpTransaction::HandleContentStart() #endif // notify the connection, give it a chance to cause a reset. PRBool reset = PR_FALSE; - mConnection->OnHeadersAvailable(this, mResponseHead, &reset); + mConnection->OnHeadersAvailable(this, mRequestHead, mResponseHead, &reset); // looks like we should ignore this response, resetting... if (reset) {