Bug 92006: Send connection: close to proxies when persistant conections are disabled.

Bug 94038: Wrong hostname in the status bar used when proxy-keepalive is enabled.

r=gagan, sr=darin on both patches
This commit is contained in:
bbaetz%cs.mcgill.ca 2001-08-10 22:04:51 +00:00
Родитель ad8d40324b
Коммит b5669c78c0
5 изменённых файлов: 60 добавлений и 6 удалений

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

@ -25,8 +25,15 @@
[scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)]
interface nsISocketTransport : nsITransport
{
readonly attribute string host;
readonly attribute long port;
/**
* Destination host and port. These are used for reporting status messages
* Since the end server may change at any time (eg persistent connections
* through proxies), a client can update this to get correct results.
* There is no other effect of setting these attributes, and if a proxy
* server is not being used, NS_ERROR_FAILURE is returned.
*/
attribute string host;
attribute long port;
/**
*

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

@ -1147,6 +1147,21 @@ nsSocketTransport::GetHost(char **aHost)
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::SetHost(const char *aHost)
{
if (!mProxyHost)
return NS_ERROR_FAILURE;
NS_ENSURE_ARG_POINTER(aHost);
CRTFREEIF(mHostName);
mHostName = nsCRT::strdup(aHost);
if (!mHostName)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::GetPort(PRInt32 *aPort)
{
@ -1155,6 +1170,16 @@ nsSocketTransport::GetPort(PRInt32 *aPort)
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::SetPort(PRInt32 aPort)
{
if (!mProxyHost)
return NS_ERROR_FAILURE;
mPort = aPort;
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::GetReuseConnection(PRBool *value)
{

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

@ -390,6 +390,15 @@ nsHttpConnection::ActivateConnection()
// in our OnStopRequest.
nsHttpTransaction *trans = mTransaction;
NS_ADDREF(trans);
// We need to tell the socket transport what origin server we're
// communicating with. This may not be the same as the original host,
// if we're talking to a proxy server using persistent connections.
// We update the connectionInfo as well, so that our logging is correct.
// See bug 94088
mSocketTransport->SetHost(mConnectionInfo->Host());
mSocketTransport->SetPort(mConnectionInfo->Port());
// fire off the read first so that we'll often detect premature EOF before
// writing to the socket, though this is not necessary.

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

@ -155,14 +155,21 @@ public:
NS_INIT_ISUPPORTS();
if (host)
mHost.Adopt(nsCRT::strdup(host));
if (proxyHost)
mProxyHost.Adopt(nsCRT::strdup(proxyHost));
if (proxyType)
mProxyType.Adopt(nsCRT::strdup(proxyType));
mPort = port == -1 ? DefaultPort() : port;
SetOriginServer(host, port);
}
nsresult SetOriginServer(const char* host, PRInt32 port)
{
if (host)
mHost.Adopt(nsCRT::strdup(host));
mPort = port == -1 ? DefaultPort(): port;
return NS_OK;
}
virtual ~nsHttpConnectionInfo()
@ -203,7 +210,7 @@ public:
PRBool UsingSSL() { return mUsingSSL; }
PRInt32 DefaultPort() { return mUsingSSL ? 443 : 80; }
private:
nsXPIDLCString mHost;
PRInt32 mPort;

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

@ -289,6 +289,9 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request,
if (NS_FAILED(rv)) return rv;
connectionType = "keep-alive";
} else if (useProxy) {
// Bug 92006
request->SetHeader(nsHttp::Connection, "close");
}
const nsHttpAtom& connAtom = useProxy ? nsHttp::Proxy_Connection : nsHttp::Connection;
@ -721,6 +724,9 @@ nsHttpHandler::InitiateTransaction_Locked(nsHttpTransaction *trans,
NS_RELEASE(conn);
return rv;
}
} else {
// Update the connectionInfo (bug 94038)
conn->ConnectionInfo()->SetOriginServer(ci->Host(), ci->Port());
}
// assign the connection to the transaction.