Fix for 31164, possibly 35658, and prep work for 31174.

1) Passing the proxy hostname and port to the underlying socket
   and changing all users that appeared in lxr.

2) (psm-glue) registering with the cache manager to allow local loopback so that
   psm will work with a proxy.

3) (psm-glue) Storing proxy information in psmSocketInfo.

most reviewed by gagan@netscape.com.
This commit is contained in:
dougt%netscape.com 2000-05-19 22:56:12 +00:00
parent ebf9115175
commit d83290854c
26 changed files with 308 additions and 143 deletions

View File

@ -157,7 +157,7 @@ nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
@ -182,7 +182,7 @@ nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
@ -201,7 +201,7 @@ nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);

View File

@ -202,7 +202,7 @@ nsFingerChannel::OpenInputStream(nsIInputStream **_retval)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
@ -234,7 +234,7 @@ nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;

View File

@ -72,7 +72,7 @@ CBSConnection.prototype.connect = function(host, port, bind, tcp_flag)
this.bind = bind;
this.tcp_flag = tcp_flag;
this._channel = this._sockService.createTransport (host, port, host, 0, 0);
this._channel = this._sockService.createTransport (host, port, null, 0, 0, 0);
if (!this._channel)
throw ("Error opening channel.");

View File

@ -36,10 +36,15 @@
interface nsIPSMSocketInfo : nsISupports {
readonly attribute string hostName;
readonly attribute PRInt32 hostPort;
readonly attribute string proxyName;
readonly attribute PRInt32 proxyPort;
readonly attribute psmtControlStar controlPtr;
readonly attribute cmSocketStar socketPtr;
readonly attribute nsFileDescStar fileDescPtr;
void getPickledStatus(out charStar pickledStatus);
};

View File

@ -57,6 +57,8 @@
#include "nsIScriptSecurityManager.h"
#include "nsICertificatePrincipal.h"
#include "nsIProtocolProxyService.h"
#define PSM_VERSION_REG_KEY "/Netscape/Personal Security Manager"
#ifdef WIN32
@ -72,7 +74,7 @@
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kProtocolProxyServiceCID, NS_PROTOCOLPROXYSERVICE_CID);
nsPSMComponent* nsPSMComponent::mInstance = nsnull;
@ -565,6 +567,10 @@ nsPSMComponent::GetControlConnection( CMT_CONTROL * *_retval )
PR_FREEIF(profileName);
nsCOMPtr<nsIProtocolProxyService> proxySvc = do_GetService(kProtocolProxyServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
proxySvc->AddNoProxyFor("127.0.0.1", mControl->port);
*_retval = mControl;
return NS_OK;
}

View File

@ -140,15 +140,10 @@ nsPSMShimConnect(CMTSocket sock, short port, char *path)
switch (errcode)
{
case PR_IS_CONNECTED_ERROR:
case PR_IN_PROGRESS_ERROR:
rv = CMTSuccess;
break;
case PR_IN_PROGRESS_ERROR:
case PR_IO_TIMEOUT_ERROR:
#ifdef WIN32
case PR_WOULD_BLOCK_ERROR:
case PR_INVALID_ARGUMENT_ERROR:
#endif
default:
rv = CMTFailure;
break;

View File

@ -50,13 +50,22 @@ public:
nsresult SetControlPtr(CMT_CONTROL *aControlPtr);
nsresult SetFileDescPtr(PRFileDesc *aControlPtr);
nsresult SetHostName(char *aHostName);
nsresult SetProxyName(char *aName);
nsresult SetHostPort(PRInt32 aPort);
nsresult SetProxyPort(PRInt32 aPort);
nsresult SetPickledStatus();
protected:
CMT_CONTROL* mControl;
CMSocket* mSocket;
PRFileDesc* mFd;
nsString mHostName;
PRInt32 mHostPort;
nsString mProxyName;
PRInt32 mProxyPort;
unsigned char* mPickledStatus;
};
@ -68,33 +77,14 @@ nsSSLIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeou
nsresult result;
PRStatus rv = PR_SUCCESS;
CMTStatus status = CMTFailure;
char* hostName;
/* Set the error in case of failure. */
PR_SetError(PR_UNKNOWN_ERROR, status);
if (!fd || !addr || !fd->secret)
if (!fd || !addr || !fd->secret || !gPSMService)
return PR_FAILURE;
if (gPSMService == nsnull)
{
result = nsServiceManager::GetService( PSM_COMPONENT_PROGID,
NS_GET_IID(nsIPSMComponent),
(nsISupports**)&gPSMService); //FIX leak one per app run
if (NS_FAILED(result))
return PR_FAILURE;
}
// Make the socket non-blocking...
PRSocketOptionData opt;
opt.option = PR_SockOpt_Nonblocking;
opt.value.non_blocking = PR_FALSE;
rv = PR_SetSocketOption(fd->lower, &opt);
if (PR_SUCCESS != rv)
return PR_FAILURE;
char ipBuffer[PR_NETDB_BUF_SIZE];
rv = PR_NetAddrToString(addr, (char*)&ipBuffer, PR_NETDB_BUF_SIZE);
if (rv != PR_SUCCESS)
@ -106,39 +96,68 @@ nsSSLIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeou
strcpy(ipBuffer, ipBuffer + 7);
}
CMT_CONTROL *control;
result = gPSMService->GetControlConnection(&control);
if (result != PR_SUCCESS)
return PR_FAILURE;
CMSocket* cmsock = (CMSocket *)PR_Malloc(sizeof(CMSocket));
if (!cmsock)
return PR_FAILURE;
memset(cmsock, 0, sizeof(CMSocket));
CMT_CONTROL *control;
result = gPSMService->GetControlConnection(&control);
if (result != PR_SUCCESS)
{
PR_FREEIF(cmsock)
return PR_FAILURE;
}
cmsock->fd = fd->lower;
cmsock->isUnix = PR_FALSE;
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
infoObject->GetHostName(&hostName);
infoObject->SetControlPtr(control);
infoObject->SetSocketPtr(cmsock);
status = CMT_OpenSSLConnection(control,
cmsock,
SSM_REQUEST_SSL_DATA_SSL,
PR_ntohs(addr->inet.port),
ipBuffer,
(hostName ? hostName : ipBuffer),
CM_FALSE,
nsnull);
char* proxyName;
char* hostName;
infoObject->GetProxyName(&proxyName);
infoObject->GetHostName(&hostName);
if (!proxyName)
{
// Direct connection
status = CMT_OpenSSLConnection(control,
cmsock,
SSM_REQUEST_SSL_DATA_SSL,
PR_ntohs(addr->inet.port),
ipBuffer,
(hostName ? hostName : ipBuffer),
CM_FALSE,
nsnull);
}
else
{
// not supported yet.
return PR_FAILURE;
#if 0
PRInt32 destPort;
infoObject->GetProxyPort(&destPort);
status = CMT_OpenSSLProxyConnection(control,
cmsock,
destPort,
proxyName, // wants IP
hostName);
#endif
}
Recycle(hostName);
Recycle(proxyName);
if (CMTSuccess == status)
{
// since our stuff can block, what we want to do is return PR_FAILURE,
@ -172,12 +191,11 @@ nsSSLIOLayerClose(PRFileDesc *fd)
infoObject->GetSocketPtr(&socket);
infoObject->SetPickledStatus();
if (((PRStatus) CMT_GetSSLDataErrorCode(control, socket, &errorCode)) == PR_SUCCESS)
{
CMT_DestroyDataConnection(control, socket);
NS_RELEASE(infoObject); // if someone is interested in us, the better have an addref.
fd->identity = PR_INVALID_IO_LAYER;
}
CMT_GetSSLDataErrorCode(control, socket, &errorCode);
CMT_DestroyDataConnection(control, socket);
NS_RELEASE(infoObject); // if someone is interested in us, the better have an addref.
fd->identity = PR_INVALID_IO_LAYER;
return (PRStatus)errorCode;
}
@ -340,7 +358,10 @@ nsPSMSocketInfo::SetFileDescPtr(PRFileDesc *aFilePtr)
NS_IMETHODIMP
nsPSMSocketInfo::GetHostName(char * *aHostName)
{
*aHostName = mHostName.ToNewCString();
if (mHostName.IsEmpty())
*aHostName = nsnull;
else
*aHostName = mHostName.ToNewCString();
return NS_OK;
}
@ -352,6 +373,56 @@ nsPSMSocketInfo::SetHostName(char *aHostName)
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetHostPort(PRInt32 *aPort)
{
*aPort = mHostPort;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetHostPort(PRInt32 aPort)
{
mHostPort = aPort;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetProxyName(char * *aName)
{
if (mProxyName.IsEmpty())
*aName = nsnull;
else
*aName = mProxyName.ToNewCString();
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetProxyName(char *aName)
{
mProxyName.AssignWithConversion(aName);
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetProxyPort(PRInt32 *aPort)
{
*aPort = mProxyPort;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetProxyPort(PRInt32 aPort)
{
mProxyPort = aPort;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetPickledStatus()
{
@ -396,7 +467,12 @@ nsPSMSocketInfo::GetPickledStatus(char * *pickledStatusString)
}
nsresult
nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports** info)
nsSSLIOLayerNewSocket( const char *host,
PRInt32 port,
const char *proxyHost,
PRInt32 proxyPort,
PRFileDesc **fd,
nsISupports** info)
{
static PRBool firstTime = PR_TRUE;
if (firstTime)
@ -408,7 +484,16 @@ nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports** info)
nsSSLIOLayerMethods.close = nsSSLIOLayerClose;
nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
nsSSLIOLayerMethods.write = nsSSLIOLayerWrite;
nsresult result = nsServiceManager::GetService( PSM_COMPONENT_PROGID,
NS_GET_IID(nsIPSMComponent),
(nsISupports**)&gPSMService);
if (NS_FAILED(result))
return PR_FAILURE;
firstTime = PR_FALSE;
}
@ -419,6 +504,14 @@ nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports** info)
/* Get a normal NSPR socket */
sock = PR_NewTCPSocket();
if (! sock) return NS_ERROR_OUT_OF_MEMORY;
// Make the socket non-blocking...
PRSocketOptionData opt;
opt.option = PR_SockOpt_Nonblocking;
opt.value.non_blocking = PR_FALSE;
rv = PR_SetSocketOption(sock, &opt);
if (PR_SUCCESS != rv)
return PR_FAILURE;
layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);
if (! layer)
@ -436,7 +529,12 @@ nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports** info)
}
NS_ADDREF(infoObject);
infoObject->SetHostName((char*)hostName);
infoObject->SetHostName((char*)host);
infoObject->SetHostPort(port);
infoObject->SetProxyName((char*)proxyHost);
infoObject->SetProxyPort(proxyPort);
layer->secret = (PRFilePrivate*) infoObject;
rv = PR_PushIOLayer(sock, PR_GetLayersIdentity(sock), layer);

View File

@ -30,8 +30,10 @@
// define taken from 4.x cartman glue code.
#define SSMSTRING_PADDED_LENGTH(x) ((((x)+3)/4)*4)
nsresult nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports **securityInfo);
nsresult nsSSLIOLayerNewSocket(const char *host,
PRInt32 port,
const char *proxyHost,
PRInt32 proxyPort,
PRFileDesc **fd,
nsISupports **securityInfo);
#endif /* _NSSSLIOLAYER_H */

View File

@ -76,8 +76,19 @@ nsSSLSocketProvider::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_IMETHODIMP
nsSSLSocketProvider::NewSocket(const char *hostName, PRFileDesc **_result, nsISupports **securityInfo)
nsSSLSocketProvider::NewSocket(const char *host,
PRInt32 port,
const char *proxyHost,
PRInt32 proxyPort,
PRFileDesc **_result,
nsISupports **securityInfo)
{
nsresult rv = nsSSLIOLayerNewSocket(hostName, _result, securityInfo);
nsresult rv = nsSSLIOLayerNewSocket(host,
port,
proxyHost,
proxyPort,
_result,
securityInfo);
return (NS_FAILED(rv)) ? NS_ERROR_SOCKET_CREATE_FAILED : NS_OK;
}

View File

@ -81,7 +81,7 @@ nsresult nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, PRInt3
m_readCount = -1; // with socket connections we want to read as much data as arrives
m_startPosition = 0;
rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, 0, 0, 0, getter_AddRefs(m_channel));
if (NS_FAILED(rv)) return rv;
m_socketIsOpen = PR_FALSE;

View File

@ -589,9 +589,9 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
}
if (m_overRideUrlConnectionInfo)
rv = socketService->CreateTransportOfType(connectionType, m_logonHost.GetBuffer(), m_logonPort, nsnull, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, m_logonHost.GetBuffer(), m_logonPort, nsnull, 0, 0, 0, getter_AddRefs(m_channel));
else
rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, 0, 0, 0, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv))
rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream));

View File

@ -38,13 +38,16 @@ interface nsISocketTransportService : nsISupports
*/
nsIChannel createTransport(in string host,
in long port,
in string printHost,
in string proxyHost,
in long proxyPort,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
nsIChannel createTransportOfType(in string socketType,
in string host,
in long port,
in string printHost,
in string proxyHost,
in long proxyPort,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);

View File

@ -131,7 +131,8 @@ nsSocketTransport::nsSocketTransport():
mMonitor(nsnull),
mOperation(eSocketOperation_None),
mPort(0),
mPrintHost(nsnull),
mProxyHost(nsnull),
mProxyPort(0),
mReadWriteState(0),
mSelectFlags(0),
mService(nsnull),
@ -222,7 +223,7 @@ nsSocketTransport::~nsSocketTransport()
NS_IF_RELEASE (mService);
CRTFREEIF (mPrintHost);
CRTFREEIF (mProxyHost);
CRTFREEIF (mHostName);
CRTFREEIF (mSocketType);
@ -245,7 +246,8 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
const char* aHost,
PRInt32 aPort,
const char* aSocketType,
const char* aPrintHost,
const char* aProxyHost,
PRInt32 aProxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
@ -259,24 +261,27 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
mService = aService;
NS_ADDREF(mService);
mPort = aPort;
mPort = aPort;
mProxyPort = aProxyPort;
if (aHost && *aHost)
{
mHostName = nsCRT::strdup(aHost);
if (!mHostName)
rv = NS_ERROR_OUT_OF_MEMORY;
}
// hostname was nsnull or empty...
else
rv = NS_ERROR_FAILURE;
if (aPrintHost)
}
else // hostname was nsnull or empty...
{
mPrintHost = nsCRT::strdup(aPrintHost);
if (!mPrintHost)
rv = NS_ERROR_OUT_OF_MEMORY;
rv = NS_ERROR_FAILURE;
}
if (aProxyHost && *aProxyHost)
{
mProxyHost = nsCRT::strdup(aProxyHost);
if (!mProxyHost)
rv = NS_ERROR_OUT_OF_MEMORY;
}
if (NS_SUCCEEDED(rv) && aSocketType)
{
mSocketType = nsCRT::strdup(aSocketType);
@ -680,7 +685,7 @@ nsresult nsSocketTransport::doResolveHost(void)
// XXX: The list of ports must be restricted - see net_bad_ports_table[] in
// mozilla/network/main/mkconect.c
//
mNetAddress.ipv6.port = PR_htons(mPort);
mNetAddress.ipv6.port = PR_htons(((mProxyPort != -1) ? mProxyPort : mPort));
NS_WITH_SERVICE(nsIDNSService,
pDNSService,
@ -694,7 +699,9 @@ nsresult nsSocketTransport::doResolveHost(void)
//
PR_ExitMonitor(mMonitor);
rv = pDNSService->Lookup(mHostName, this, nsnull,
rv = pDNSService->Lookup(mProxyHost ? mProxyHost : mHostName,
this,
nsnull,
getter_AddRefs(mDNSRequest));
//
// Aquire the SocketTransport lock again...
@ -778,7 +785,12 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags)
rv = pProviderService->GetSocketProvider(mSocketType, getter_AddRefs(pProvider));
if (NS_SUCCEEDED(rv))
rv = pProvider->NewSocket(mHostName, &mSocketFD, getter_AddRefs(mSecurityInfo));
rv = pProvider->NewSocket(mHostName,
mPort,
mProxyHost,
mProxyPort,
&mSocketFD,
getter_AddRefs(mSecurityInfo));
}
if (mSocketFD) {
@ -1726,8 +1738,17 @@ nsSocketTransport::GetOriginalURI(nsIURI* *aURL)
{
nsStdURL *url;
url = new nsStdURL(nsnull);
url->SetHost(mHostName);
url->SetPort(mPort);
if( mProxyHost )
{
url->SetHost(mProxyHost);
url->SetPort(mProxyPort);
}
else
{
url->SetHost(mHostName);
url->SetPort(mPort);
}
nsresult rv;
rv = CallQueryInterface(url, aURL);
@ -2350,10 +2371,7 @@ nsSocketTransport::fireStatus(PRUint32 aCode)
nsresult rv = GetSocketErrorString(aCode, getter_Copies(tempmesg));
nsAutoString mesg(tempmesg);
if (mPrintHost)
mesg.AppendWithConversion(mPrintHost);
else
mesg.AppendWithConversion(mHostName);
mesg.AppendWithConversion(mHostName);
if (NS_FAILED(rv)) return rv;

View File

@ -137,7 +137,8 @@ public:
const char* aHost,
PRInt32 aPort,
const char* aSocketType,
const char* aPrintHost, // This host is used for status mesg
const char* aProxyHost,
PRInt32 aProxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
@ -210,6 +211,7 @@ protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIProgressEventSink> mEventSink;
char* mHostName;
PRInt32 mPort;
PRIntervalTime mLastActiveTime;
PRCList mListLink;
PRUint32 mLoadAttributes;
@ -220,8 +222,8 @@ protected:
nsSocketOperation mOperation;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsISupports> mSecurityInfo;
PRInt32 mPort;
char* mPrintHost; // not the proxy
PRInt32 mProxyPort;
char* mProxyHost;
nsCOMPtr<nsISupports> mReadContext;
nsCOMPtr<nsIStreamListener> mReadListener;
nsCOMPtr<nsIBufferInputStream> mReadPipeIn;

View File

@ -489,12 +489,13 @@ nsSocketTransportService::Run(void)
NS_IMETHODIMP
nsSocketTransportService::CreateTransport(const char* aHost,
PRInt32 aPort,
const char* aPrintHost,
const char* proxyHost,
PRInt32 proxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** aResult)
{
return CreateTransportOfType(nsnull, aHost, aPort, aPrintHost,
return CreateTransportOfType(nsnull, aHost, aPort, proxyHost, proxyPort,
bufferSegmentSize, bufferMaxSize, aResult);
}
@ -502,7 +503,8 @@ NS_IMETHODIMP
nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
const char* aHost,
PRInt32 aPort,
const char* aPrintHost,
const char* proxyHost,
PRInt32 proxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** aResult)
@ -527,7 +529,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
// Create and initialize a new connection object...
NS_NEWXPCOM(transport, nsSocketTransport);
if (transport) {
rv = transport->Init(this, aHost, aPort, aSocketType, aPrintHost,
rv = transport->Init(this, aHost, aPort, aSocketType, proxyHost, proxyPort,
bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
delete transport;

View File

@ -157,7 +157,7 @@ nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
@ -182,7 +182,7 @@ nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
@ -201,7 +201,7 @@ nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel));
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);

View File

@ -202,7 +202,7 @@ nsFingerChannel::OpenInputStream(nsIInputStream **_retval)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
@ -234,7 +234,7 @@ nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, mHost, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;

View File

@ -127,7 +127,7 @@ nsFtpConnectionThread::Process() {
if (NS_FAILED(rv)) return rv;
// build our own
rv = mSTS->CreateTransport(host, mPort, host,
rv = mSTS->CreateTransport(host, mPort, nsnull, 0,
FTP_COMMAND_CHANNEL_SEG_SIZE,
FTP_COMMAND_CHANNEL_MAX_SIZE,
getter_AddRefs(mCPipe)); // the command channel
@ -1391,7 +1391,7 @@ nsFtpConnectionThread::R_pasv() {
// now we know where to connect our data channel
rv = mSTS->CreateTransport(mIPv6ServerAddress ? mIPv6ServerAddress : host.GetBuffer(),
port, nsnull,
port, nsnull, 0,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mDPipe)); // the data channel
if (NS_FAILED(rv)) return FTP_ERROR;

View File

@ -971,14 +971,22 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
}
}
if (usingProxy)
rv = CreateTransport(proxy, proxyPort, host, bufferSegmentSize,
bufferMaxSize, &trans);
else
rv = CreateTransport(host, port, host, bufferSegmentSize,
bufferMaxSize, &trans);
rv = CreateTransport( host,
port,
proxy,
proxyPort,
bufferSegmentSize,
bufferMaxSize,
&trans );
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISocketTransport> trans = do_QueryInterface (*o_pTrans, &rv);
if (NS_SUCCEEDED (rv))
{
trans->SetSocketTimeout(mRequestTimeout);
trans->SetSocketConnectTimeout(mConnectTimeout);
}
}
// Put it in the table...
@ -1000,7 +1008,8 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
nsresult nsHTTPHandler::CreateTransport(const char* host,
PRInt32 port,
const char* aPrintHost,
const char* proxyHost,
PRInt32 proxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans)
@ -1011,17 +1020,14 @@ nsresult nsHTTPHandler::CreateTransport(const char* host,
if (NS_FAILED (rv))
return rv;
rv = sts->CreateTransport(host, port, aPrintHost, bufferSegmentSize,
bufferMaxSize, o_pTrans);
if (NS_SUCCEEDED (rv))
{
nsCOMPtr<nsISocketTransport> trans = do_QueryInterface (*o_pTrans, &rv);
if (NS_SUCCEEDED (rv))
{
trans->SetSocketTimeout(mRequestTimeout);
trans->SetSocketConnectTimeout(mConnectTimeout);
}
}
rv = sts->CreateTransport(host,
port,
proxyHost,
proxyPort,
bufferSegmentSize,
bufferMaxSize,
o_pTrans);
return rv;
}

View File

@ -103,6 +103,7 @@ public:
virtual nsresult CreateTransport(const char* host, PRInt32 port,
const char* aPrintHost,
PRBool usingProxy,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans);

View File

@ -55,10 +55,13 @@ nsHTTPSHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
return rv;
}
nsresult nsHTTPSHandler::CreateTransport(const char* host, PRInt32 port,
const char* printHost,
PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize,
nsIChannel** o_pTrans)
nsresult nsHTTPSHandler::CreateTransport(const char* host,
PRInt32 port,
const char* proxyHost,
PRInt32 proxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans)
{
nsresult rv;
@ -66,7 +69,13 @@ nsresult nsHTTPSHandler::CreateTransport(const char* host, PRInt32 port,
kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
return rv = sts->CreateTransportOfType("ssl", host, port,
printHost, bufferSegmentSize, bufferMaxSize, o_pTrans);
return sts->CreateTransportOfType( "ssl",
host,
port,
proxyHost,
proxyPort,
bufferSegmentSize,
bufferMaxSize,
o_pTrans);
}

View File

@ -69,9 +69,11 @@ public:
* make a new channel.
**/
virtual nsresult CreateTransport(const char* host, PRInt32 port,
const char* printHost,
PRUint32 bufferSegmentSize,
virtual nsresult CreateTransport(const char* host,
PRInt32 port,
const char* proxyHost,
PRInt32 proxyPort,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans);
};

View File

@ -31,7 +31,12 @@
[noscript, uuid(0906de00-5414-11d3-bbc8-0000861d1237)]
interface nsISocketProvider : nsISupports {
void NewSocket ( in string hostName, out nsFileDescStar fileDesc, out nsISupports securityInfo );
void NewSocket(in string host,
in long port,
in string proxyHost,
in long proxyPort,
out nsFileDescStar fileDesc,
out nsISupports securityInfo );
};

View File

@ -249,7 +249,7 @@ main(int argc, char* argv[])
// Create the socket transport...
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, hostName, 0, 0, &transport);
rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, 0, &transport);
// This stuff is used to test the output stream
#if 0

View File

@ -164,7 +164,7 @@ main(int argc, char* argv[])
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, hostName, 0, 0, &transport);
rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, 0, &transport);
if (NS_SUCCEEDED(rv)) {
transport->AsyncRead(nsnull, new InputTestConsumer);

View File

@ -329,7 +329,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
// Create a socket transport...
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = sts->CreateTransport(aHostName, aPort, aHostName, 0, 0, &mTransport);
rv = sts->CreateTransport(aHostName, aPort, nsnull, 0, 0, 0, &mTransport);
if (NS_SUCCEEDED(rv)) {
// Set up the notification callbacks to provide a progress event sink.
// That way we exercise the progress notification proxy code.