fixes bug 166396 "embedders should be able to override the default socket

type used for HTTP connections" r=dougt sr=rpotts a=chofmann
This commit is contained in:
darin%netscape.com 2002-09-06 06:36:17 +00:00
Родитель 0717b547f2
Коммит 893a5843dc
5 изменённых файлов: 37 добавлений и 2 удалений

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

@ -416,6 +416,10 @@ pref("network.http.proxy.version", "1.1"); // default
// enable caching of http documents
pref("network.http.use-cache", true);
// this preference can be set to override the socket type used for normal
// HTTP traffic. an empty value indicates the normal TCP/IP socket type.
pref("network.http.default-socket-type", "");
pref("network.http.keep-alive", true); // set it to false in case of problems
pref("network.http.proxy.keep-alive", true);
pref("network.http.keep-alive.timeout", 300);

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

@ -2484,8 +2484,8 @@ nsHttpChannel::SetReferrer(nsIURI *referrerIn, PRUint32 referrerType)
// Path is of the form "//123/http://foo/bar", with a variable number of digits.
// To figure out where the "real" URL starts, search path for a '/', starting at
// the third character.
PRUint32 slashIndex = path.FindChar('/', 2);
if (slashIndex == -1) return NS_ERROR_FAILURE;
PRInt32 slashIndex = path.FindChar('/', 2);
if (slashIndex < 0) return NS_ERROR_FAILURE;
// Replace |referrer| with a URI without wyciwyg://123/.
nsCAutoString newReferrer;

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

@ -500,6 +500,8 @@ nsHttpConnection::CreateTransport()
if (mConnectionInfo->UsingSSL())
type = "ssl";
else
type = nsHttpHandler::get()->DefaultSocketType();
nsCOMPtr<nsITransport> transport;
rv = sts->CreateTransportOfType(type,

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

@ -48,6 +48,8 @@
#include "nsIPrefService.h"
#include "nsIPrefBranchInternal.h"
#include "nsIPrefLocalizedString.h"
#include "nsISocketProviderService.h"
#include "nsISocketProvider.h"
#include "nsPrintfCString.h"
#include "nsCOMPtr.h"
#include "nsNetCID.h"
@ -78,6 +80,7 @@ static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kSocketProviderServiceCID, NS_SOCKETPROVIDERSERVICE_CID);
#define UA_PREF_PREFIX "general.useragent."
#define UA_APPNAME "Mozilla"
@ -1473,6 +1476,29 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
}
if (PREF_CHANGED(HTTP_PREF("default-socket-type"))) {
nsXPIDLCString val;
rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"),
getter_Copies(val));
if (NS_SUCCEEDED(rv)) {
if (val.IsEmpty())
mDefaultSocketType.Adopt(0);
else {
// verify that this socket type is actually valid
nsCOMPtr<nsISocketProviderService> sps(
do_GetService(kSocketProviderServiceCID, &rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISocketProvider> sp;
rv = sps->GetSocketProvider(val, getter_AddRefs(sp));
if (NS_SUCCEEDED(rv)) {
// OK, this looks like a valid socket provider.
mDefaultSocketType.Assign(val);
}
}
}
}
}
//
// INTL options
//

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

@ -90,6 +90,7 @@ public:
PRUint8 RedirectionLimit() { return mRedirectionLimit; }
PRUint16 IdleTimeout() { return mIdleTimeout; }
PRUint16 MaxRequestAttempts() { return mMaxRequestAttempts; }
const char *DefaultSocketType() { return mDefaultSocketType.get(); /* ok to return null */ }
nsIIDNService *IDNConverter() { return mIDNConverter; }
nsHttpAuthCache *AuthCache() { return mAuthCache; }
@ -276,6 +277,8 @@ private:
nsCString mAcceptEncodings;
nsCString mAcceptCharsets;
nsXPIDLCString mDefaultSocketType;
// cache support
nsCOMPtr<nsICacheSession> mCacheSession_ANY;
nsCOMPtr<nsICacheSession> mCacheSession_MEM;