checking bbaetz's patch for bug 89500 "SOCKS: only http|https re-directted in (post Mozilla 0.9.2)"

patch=bbaetz, r=dougt, sr=darin
This commit is contained in:
darin%netscape.com 2001-09-13 02:21:05 +00:00
Родитель 0d91fff56d
Коммит 5a2d9f0d2d
86 изменённых файлов: 686 добавлений и 397 удалений

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

@ -525,7 +525,7 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetURIType(PRInt16 *result)
nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
return NS_OK;

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

@ -77,10 +77,10 @@ nsLDAPProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
// getter method for uritype attribute
// getter method for protocol flags attribute
//
NS_IMETHODIMP
nsLDAPProtocolHandler::GetURIType(PRInt16 *result)
nsLDAPProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE;
return NS_OK;

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

@ -24,3 +24,4 @@ connectionFailure=The connection was refused when attempting to contact %s.
netTimeout=The operation timed out when attempting to contact %s.
repost=The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
repostConfirm=The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
fileNotFound=%s does not exist or could not be accessed. Please check the file path and try again.

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

@ -716,7 +716,7 @@ nsJSProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsJSProtocolHandler::GetURIType(PRInt16 *result)
nsJSProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;

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

@ -33,8 +33,6 @@
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
// nsDateTimeChannel methods
nsDateTimeChannel::nsDateTimeChannel() {
NS_INIT_REFCNT();
@ -52,13 +50,14 @@ NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
nsIRequestObserver)
nsresult
nsDateTimeChannel::Init(nsIURI* uri)
nsDateTimeChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
rv = mUrl->GetPort(&mPort);
if (NS_FAILED(rv) || mPort < 1)
@ -163,12 +162,17 @@ nsDateTimeChannel::Open(nsIInputStream **_retval)
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
@ -185,12 +189,17 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
@ -334,4 +343,3 @@ nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
mContentLength = aLength;
return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength);
}

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

@ -38,7 +38,7 @@
#include "nsIURI.h"
#include "nsDateTimeHandler.h"
#include "nsIStreamListener.h"
#include "nsIProxyInfo.h"
class nsDateTimeChannel
: public nsIChannel,
@ -59,7 +59,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
@ -70,7 +70,8 @@ protected:
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCString mContentType;
PRInt32 mContentLength;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
PRInt32 mPort;
nsXPIDLCString mHost;

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

@ -43,7 +43,9 @@ nsDateTimeHandler::nsDateTimeHandler() {
nsDateTimeHandler::~nsDateTimeHandler() {
}
NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler)
NS_IMPL_ISUPPORTS2(nsDateTimeHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
@ -74,8 +76,8 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsDateTimeHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
nsDateTimeHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
@ -104,6 +106,13 @@ nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_IMETHODIMP
nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsDateTimeHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
@ -111,7 +120,7 @@ nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url);
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -26,7 +26,7 @@
#ifndef nsDateTimeHandler_h___
#define nsDateTimeHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
#define DATETIME_PORT 13
@ -34,11 +34,12 @@
#define NS_DATETIMEHANDLER_CID \
{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
class nsDateTimeHandler : public nsIProtocolHandler
class nsDateTimeHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsDateTimeHandler methods:
nsDateTimeHandler();

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

@ -62,7 +62,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
nsIRequestObserver)
nsresult
nsFingerChannel::Init(nsIURI* uri)
nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
nsXPIDLCString autoBuffer;
@ -70,6 +70,7 @@ nsFingerChannel::Init(nsIURI* uri)
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
// For security reasons, we do not allow the user to specify a
// non-default port for finger: URL's.
@ -197,7 +198,7 @@ nsFingerChannel::Open(nsIInputStream **_retval)
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;
@ -220,7 +221,7 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;

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

@ -35,6 +35,7 @@
#include "nsFingerHandler.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIProxyInfo.h"
class nsFingerChannel
: public nsIChannel,
@ -55,7 +56,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
@ -80,6 +81,7 @@ protected:
nsCOMPtr<nsISupports> mResponseContext;
nsCOMPtr<nsITransport> mTransport;
nsCOMPtr<nsIRequest> mTransportRequest;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsresult mStatus;
protected:

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

@ -43,7 +43,9 @@ nsFingerHandler::nsFingerHandler() {
nsFingerHandler::~nsFingerHandler() {
}
NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler)
NS_IMPL_ISUPPORTS2(nsFingerHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
@ -74,8 +76,8 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsFingerHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
nsFingerHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
@ -104,6 +106,13 @@ nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_IMETHODIMP
nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsFingerHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
@ -111,7 +120,7 @@ nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url);
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -26,7 +26,9 @@
#ifndef nsFingerHandler_h___
#define nsFingerHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
class nsIProxyInfo;
#define FINGER_PORT 79
@ -35,11 +37,12 @@
{ 0x76d6d5d8, 0x1dd2, 0x11b2, \
{0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} }
class nsFingerHandler : public nsIProtocolHandler
class nsFingerHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsFingerHandler methods:
nsFingerHandler();

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

@ -59,7 +59,7 @@ NS_IMETHODIMP inBitmapProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP inBitmapProtocolHandler::GetURIType(PRInt16 *result)
NS_IMETHODIMP inBitmapProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE;
return NS_OK;

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

@ -163,8 +163,9 @@ function IRCProtocolHandler()
IRCProtocolHandler.prototype.scheme = "irc";
IRCProtocolHandler.prototype.defaultPort = 6667;
IRCProtocolHandler.prototype.URIType =
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE;
IRCProtocolHandler.prototype.protocolFlags =
nsIProtocolHandler.URI_NORELATIVE |
nsIProtocolHandler.ALLOWS_PROXY;
IRCProtocolHandler.prototype.allowPort =
function (aPort, aScheme)

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

@ -79,7 +79,21 @@ function bc_connect(host, port, bind, tcp_flag, observer)
this.bind = bind;
this.tcp_flag = tcp_flag;
this._transport = this._sockService.createTransport (host, port, null, -1,
// Lets get a transportInfo for this
var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
getService().
QueryInterface(Components.interfaces.nsIProtocolProxyService);
if (!pps)
throw ("Couldn't get protocol proxy service");
var uri = Components.classes["@mozilla.org/network/simple-uri;1"].
createInstance(Components.interfaces.nsIURI);
uri.spec = "irc:" + host + ':' + port;
var info = pps.examineForProxy(uri);
this._transport = this._sockService.createTransport (host, port, info,
0, 0);
if (!this._transport)
throw ("Error creating transport.");

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

@ -1273,10 +1273,6 @@ nsresult nsFormFrame::ProcessAsURLEncoded(nsIFormProcessor* aFormProcessor, PRBo
aData.AppendWithConversion(CRLF);
}
aData += buf;
// Need to append CRLF to end of stream for compatability with Nav and IE
if (isPost) {
aData.AppendWithConversion(CRLF);
}
return rv;
}

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

@ -94,7 +94,7 @@ NS_IMETHODIMP nsAddbookProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
return NS_OK;
}
NS_IMETHODIMP nsAddbookProtocolHandler::GetURIType(PRInt16 *aUritype)
NS_IMETHODIMP nsAddbookProtocolHandler::GetProtocolFlags(PRUint32 *aUritype)
{
*aUritype = URI_STD;
return NS_OK;

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

@ -109,7 +109,7 @@ nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName,
m_startPosition = 0;
rv = socketService->CreateTransportOfType(connectionType, aHostName,
aGetPort, nsnull, -1, 0, 0,
aGetPort, nsnull, 0, 0,
getter_AddRefs(m_transport));
if (NS_FAILED(rv)) return rv;

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

@ -279,7 +279,7 @@ nsSmtpService::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
return NS_OK;
}
NS_IMETHODIMP nsSmtpService::GetURIType(PRInt16 *result)
NS_IMETHODIMP nsSmtpService::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE;
return NS_OK;

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

@ -614,9 +614,9 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
connectionType = "ssl-forcehandshake";
if (m_overRideUrlConnectionInfo)
rv = socketService->CreateTransportOfType(connectionType, m_logonHost.get(), m_logonPort, nsnull, -1, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, m_logonHost.get(), m_logonPort, nsnull, 0, 0, getter_AddRefs(m_channel));
else
rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, -1, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, 0, 0, getter_AddRefs(m_channel));
// Ensure that the socket can get the notification callbacks
nsCOMPtr<nsIInterfaceRequestor> callbacks;

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

@ -3165,7 +3165,7 @@ NS_IMETHODIMP nsImapService::GetDefaultPort(PRInt32 *aDefaultPort)
return NS_OK;
}
NS_IMETHODIMP nsImapService::GetURIType(PRInt16 *result)
NS_IMETHODIMP nsImapService::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
return NS_OK;

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

@ -466,7 +466,7 @@ NS_IMETHODIMP nsMailboxService::AllowPort(PRInt32 port, const char *scheme, PRBo
return NS_OK;
}
NS_IMETHODIMP nsMailboxService::GetURIType(PRInt16 *result)
NS_IMETHODIMP nsMailboxService::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
return NS_OK;

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

@ -326,7 +326,7 @@ NS_IMETHODIMP nsPop3Service::GetDefaultDoBiff(PRBool *aDoBiff)
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::GetURIType(PRInt16 *result)
NS_IMETHODIMP nsPop3Service::GetProtocolFlags(PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = URI_NORELATIVE;

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

@ -1245,7 +1245,7 @@ nsNntpService::GetDefaultServerPort(PRBool isSecure, PRInt32 *aDefaultPort)
return rv;
}
NS_IMETHODIMP nsNntpService::GetURIType(PRInt16 *aUritype)
NS_IMETHODIMP nsNntpService::GetProtocolFlags(PRUint32 *aUritype)
{
NS_ENSURE_ARG_POINTER(aUritype);
*aUritype = URI_NORELATIVE;

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

@ -112,7 +112,7 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsJARProtocolHandler::GetURIType(PRInt16 *result)
nsJARProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
/* Although jar uris have their own concept of relative urls

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

@ -66,7 +66,7 @@ NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
return NS_OK;
}
NS_IMETHODIMP nsIconProtocolHandler::GetURIType(PRInt16 *result)
NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;

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

@ -62,6 +62,8 @@
#include "nsIScriptablePlugin.h"
#include "nsICachingChannel.h"
#include "nsHashtable.h"
#include "nsIProxyInfo.h"
#include "nsPluginLogging.h"
#include "nsAppDirectoryServiceDefs.h"
@ -1577,6 +1579,7 @@ NS_IMPL_ISUPPORTS3(nsPluginStreamListenerPeer,
nsIHttpHeaderVisitor)
////////////////////////////////////////////////////////////////////////
/* Called as a result of GetURL and PostURL */
////////////////////////////////////////////////////////////////////////
nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
@ -2876,8 +2879,6 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
nsCOMPtr<nsIProtocolProxyService> proxyService;
nsCOMPtr<nsIIOService> ioService;
PRBool isProxyEnabled;
nsXPIDLCString proxyHost, proxyType;
PRInt32 proxyPort;
proxyService = do_GetService(kProtocolProxyServiceCID, &res);
if (NS_FAILED(res) || !proxyService) {
@ -2907,19 +2908,30 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
return res;
}
nsCOMPtr<nsIProxyInfo> pi;
res = proxyService->ExamineForProxy(uriIn,
getter_Copies(proxyHost),
&proxyPort,
getter_Copies(proxyType));
getter_AddRefs(pi));
if (NS_FAILED(res)) {
return res;
}
if (!isProxyEnabled || !proxyHost.get() || proxyPort <= 0) {
if (!pi || !pi->Host() || pi->Port() <= 0) {
*result = PL_strdup("DIRECT");
} else if (!nsCRT::strcasecmp(pi->Type(), "http")) {
*result = PR_smprintf("PROXY %s:%d", pi->Host(), pi->Port());
} else if (!nsCRT::strcasecmp(pi->Type(), "socks4")) {
*result = PR_smprintf("SOCKS %s:%d", pi->Host(), pi->Port());
} else if (!nsCRT::strcasecmp(pi->Type(), "socks")) {
// XXX - this is socks5, but there is no API for us to tell the
// plugin that fact. SOCKS for now, in case the proxy server
// speaks SOCKS4 as well. See bug 78176
// For a long time this was returning an http proxy type, so
// very little is probably broken by this
*result = PR_smprintf("SOCKS %s:%d", pi->Host(), pi->Port());
} else {
NS_ASSERTION(PR_FALSE, "Unknown proxy type!");
*result = PL_strdup("DIRECT");
}
else {
*result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost, proxyPort);
}
if (nsnull == *result) {

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

@ -11,8 +11,10 @@ nsIFileTransportService.idl
nsIPasswordManager.idl
nsIPrompt.idl
nsIProtocolProxyService.idl
nsIProxiedProtocolHandler.idl
nsIProxyAutoConfig.idl
nsIProxyAutoConfigUtils.idl
nsIProxyInfo.idl
nsIProxy.idl
nsIRequest.idl
nsISocketTransportService.idl

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

@ -46,9 +46,11 @@ XPIDLSRCS = \
nsIPrompt.idl \
nsIProtocolHandler.idl \
nsIProtocolProxyService.idl \
nsIProxiedProtocolHandler.idl \
nsIProxy.idl \
nsIProxyAutoConfig.idl \
nsIProxyAutoConfigUtils.idl \
nsIProxyInfo.idl \
nsIRequest.idl \
nsITransport.idl \
nsISocketTransport.idl \

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

@ -48,8 +48,10 @@ XPIDLSRCS = \
.\nsIPrompt.idl \
.\nsIProtocolHandler.idl \
.\nsIProtocolProxyService.idl \
.\nsIProxiedProtocolHandler.idl \
.\nsIProxyAutoConfig.idl \
.\nsIProxyAutoConfigUtils.idl \
.\nsIProxyInfo.idl \
.\nsIProxy.idl \
.\nsIRequest.idl \
.\nsITransport.idl \

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

@ -40,12 +40,12 @@ interface nsIIOService : nsISupports
nsIProtocolHandler getProtocolHandler(in string scheme);
/**
* Returns a uritype for a given scheme.
* Returns the protocol flags for a given scheme.
*
* @param scheme URI scheme
* @return returns short for uritype definition
* @return returns unsigned long for protocol flags
*/
short getURIType(in string scheme);
unsigned long getProtocolFlags(in string scheme);
/**
* This method constructs a new URI by first determining the scheme

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

@ -46,17 +46,32 @@ interface nsIProtocolHandler : nsISupports
/* standard full uri, has authority component and
has concept of relative uris (http, ftp, ...) */
const short URI_STD = 0;
const unsigned long URI_STD = 0;
/* no concept of relative uris, (about, rdf, javascript, finger, ...) */
const short URI_NORELATIVE = (1<<0);
const unsigned long URI_NORELATIVE = (1<<0);
/* no authority component (file, ...) */
const short URI_NOAUTH = (1<<1);
const unsigned long URI_NOAUTH = (1<<1);
/* This uri can be proxied via a proxy (socks or http)
* (ie irc, smtp, http, etc). If the protocol supports transparent
* proxying, the handler should implement nsIProxiedProtocolHandler
* If it supports http proxying, then it should also set the flag
* ALLOWS_PROXY_HTTP (see below)
*
* @see nsIProxiedProtocolHandler
*/
const unsigned long ALLOWS_PROXY = (1<<2);
/* This uri can be proxied using an http proxy (ie http, ftp, etc).
* You need to have ALLOWS_PROXY set as well, if you want this to do anything
*/
const unsigned long ALLOWS_PROXY_HTTP = (1<<3);
/* more to come as needed */
readonly attribute short URIType;
readonly attribute unsigned long protocolFlags;
/**
* Makes a URI object that is suitable for loading by this protocol.

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

@ -23,6 +23,8 @@
#include "nsISupports.idl"
#include "nsIURI.idl"
interface nsIProxyInfo;
%{C++
#define NS_PROTOCOLPROXYSERVICE_CID \
{ /* E9B301C0-E0E4-11d3-A1A8-0050041CAF44 */ \
@ -34,7 +36,11 @@ interface nsIProtocolProxyService : nsISupports
{
readonly attribute PRBool proxyEnabled;
void examineForProxy(in nsIURI aURI, out string host, out long port, out string type);
/** Given a uri, return a proxyInfo */
nsIProxyInfo examineForProxy(in nsIURI aURI);
/** Return a proxyInfo with the given data */
nsIProxyInfo newProxyInfo(in string type, in string host, in long port);
/**
* Add additional items in the "No proxy for" list. This is above

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

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla.
*
* The Initial Developer of the Original Code is Netscape
* Communications. Portions created by Netscape Communications are
* Copyright (C) 2001 by Netscape Communications. All
* Rights Reserved.
*
* Contributor(s): Bradley Baetz <bbaetz@netscape.com> (original author)
*
*/
#include "nsIProtocolHandler.idl"
interface nsIChannel;
interface nsIURI;
interface nsIProxyInfo;
[scriptable, uuid(0a24fed4-1dd2-11b2-a75c-9f8b9a8f9ba7)]
interface nsIProxiedProtocolHandler : nsIProtocolHandler
{
/** Create a new channel with the given proxyInfo
*
*/
nsIChannel newProxiedChannel(in nsIURI uri, in nsIProxyInfo proxyInfo);
};

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

@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Bradley Baetz <bbaetz@netscape.com> (Original Developer)
*/
#include "nsISupports.idl"
/* This interface is PRIVATE.
* It is used as an opaque cookie, and this class may change at
* any time without notice.
*
* @see nsIProtocolProxyService::GetProxyInfo
*/
native constCharPtr(const char*);
[scriptable, uuid(b65d22b0-1dd1-11b2-8f95-920e5b7b56f0)]
interface nsIProxyInfo : nsISupports
{
[noscript, notxpcom] constCharPtr Host();
[noscript, notxpcom] PRInt32 Port();
[noscript, notxpcom] constCharPtr Type();
};

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

@ -25,30 +25,33 @@
interface nsITransport;
interface nsIEventSinkGetter;
interface nsIChannel;
interface nsIProxyInfo;
[scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)]
interface nsISocketTransportService : nsISupports
{
/**
* Creates a transport for a specified host and port.
* The eventSinkGetter is used to get the appropriate callbacks
* for the socket activity from the application. These include
* the progress and the status messages like "Contacting host.."
* etc. The printHost contains the actual hostname (and not the
* proxy) for displaying in status messages.
* Creates a transport for a specified host and port.
*
* @param proxyInfo Information about any transport-layer proxying. Used
* for communicating information about proxies like socks.
* This can either be the proxyInfo attribute on an
* nsISupportsTransparentProxy (or from the protocolProxyService),
* or null for no proxying.
*
* @see nsISupportsTransparentProxy
* @see nsIProtocolProxyService::GetProxyInfo
*/
nsITransport createTransport(in string host,
in long port,
in string proxyHost,
in long proxyPort,
in nsIProxyInfo proxyInfo,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
nsITransport createTransportOfType(in string socketType,
in string host,
in long port,
in string proxyHost,
in long proxyPort,
in nsIProxyInfo proxyInfo,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
@ -56,8 +59,7 @@ interface nsISocketTransportService : nsISupports
[array, size_is(typeCount)] in string socketTypes,
in string host,
in long port,
in string proxyHost,
in long proxyPort,
in nsIProxyInfo proxyInfo,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);

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

@ -51,6 +51,7 @@
#include "nsILocalFile.h"
#include "nsIFileStreams.h"
#include "nsXPIDLString.h"
#include "nsIProtocolProxyService.h"
#include "prio.h" // for read/write flags, permissions, etc.
#include "nsNetCID.h"
@ -675,4 +676,17 @@ NS_CheckPortSafety(PRInt32 port, const char* scheme, nsIIOService* ioService = n
return NS_OK;
}
inline nsresult
NS_NewProxyInfo(const char* type, const char* host, PRInt32 port, nsIProxyInfo* *result)
{
nsresult rv;
static NS_DEFINE_CID(kPPSServiceCID, NS_PROTOCOLPROXYSERVICE_CID);
nsCOMPtr<nsIProtocolProxyService> pps = do_GetService(kPPSServiceCID,&rv);
if (NS_FAILED(rv)) return rv;
return pps->NewProxyInfo(type, host, port, result);
}
#endif // nsNetUtil_h__

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

@ -40,6 +40,8 @@
#include "nsICategoryManager.h"
#include "nsIURLParser.h"
#include "nsISupportsPrimitives.h"
#include "nsIProxiedProtocolHandler.h"
#include "nsIProxyInfo.h"
#include "nsITimelineService.h"
#include "nsEscape.h"
@ -636,14 +638,14 @@ nsIOService::ExtractUrlPart(const char *urlString, PRInt16 flag, PRUint32 *start
}
NS_IMETHODIMP
nsIOService::GetURIType(const char* scheme, PRInt16 *uritype)
nsIOService::GetProtocolFlags(const char* scheme, PRUint32 *flags)
{
nsCOMPtr<nsIProtocolHandler> handler;
nsresult rv = GetProtocolHandler(scheme, getter_AddRefs(handler));
if (NS_FAILED(rv)) {
return rv;
}
rv = handler->GetURIType(uritype);
rv = handler->GetProtocolFlags(flags);
return rv;
}
@ -708,7 +710,6 @@ nsIOService::NewFileURI(nsIFile *aSpec, nsIURI **_retval)
return NewURI(urlString, nsnull, _retval);
}
NS_IMETHODIMP
nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result)
{
@ -720,36 +721,28 @@ nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result)
rv = aURI->GetScheme(getter_Copies(scheme));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIProtocolHandler> handler;
rv = GetProtocolHandler((const char*)scheme, getter_AddRefs(handler));
nsCOMPtr<nsIProxyInfo> pi;
rv = mProxyService->ExamineForProxy(aURI, getter_AddRefs(pi));
if (NS_FAILED(rv)) return rv;
PRBool useProxy = PR_FALSE;
if (mProxyService) {
mProxyService->GetProxyEnabled(&useProxy);
if (useProxy) {
nsXPIDLCString host, type;
PRInt32 port;
rv = mProxyService->ExamineForProxy(aURI, getter_Copies(host), &port, getter_Copies(type));
if (NS_SUCCEEDED(rv) && type.get())
{
// we are going to proxy this channel and the only protocol that can do proxying is http
rv = GetProtocolHandler("http", getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIHttpProtocolHandler> httpHandler = do_QueryInterface(handler, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIProtocolHandler> handler;
if (!httpHandler)
return NS_ERROR_NULL_POINTER;
return httpHandler->NewProxyChannel(aURI, host, port, type, result);
}
}
if (pi && !nsCRT::strcmp(pi->Type(),"http")) {
// we are going to proxy this channel using an http proxy
rv = GetProtocolHandler("http", getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
} else {
rv = GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
}
rv = handler->NewChannel(aURI, result);
nsCOMPtr<nsIProxiedProtocolHandler> pph = do_QueryInterface(handler);
if (pph)
rv = pph->NewProxiedChannel(aURI, pi, result);
else
rv = handler->NewChannel(aURI, result);
return rv;
}

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

@ -28,6 +28,7 @@
#include "nsNetCID.h"
#include "nsIIOService.h"
#include "nsIEventQueueService.h"
#include "nsIProtocolHandler.h"
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@ -43,6 +44,7 @@ static PRInt32 PR_CALLBACK ProxyPrefsCallback(const char* pref, void* instance)
NS_IMPL_THREADSAFE_ISUPPORTS1(nsProtocolProxyService, nsIProtocolProxyService);
NS_IMPL_THREADSAFE_ISUPPORTS1(nsProtocolProxyService::nsProxyInfo, nsIProxyInfo);
nsProtocolProxyService::nsProtocolProxyService():
@ -324,26 +326,30 @@ nsProtocolProxyService::CanUseProxy(nsIURI* aURI)
// nsIProtocolProxyService
NS_IMETHODIMP
nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, char * *aProxyHost, PRInt32 *aProxyPort, char * *aProxyType) {
nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, nsIProxyInfo* *aResult) {
nsresult rv = NS_OK;
NS_ASSERTION(aURI, "need a uri folks.");
NS_ENSURE_ARG_POINTER(aProxyHost);
NS_ENSURE_ARG_POINTER(aProxyType);
*aProxyHost = nsnull;
*aProxyType = nsnull;
*aProxyPort = -1;
// we only know about http, https, ftp and gopher as yet...
// return nothing for others. See what happens otherwise in bug 81214
PRBool validScheme = PR_FALSE;
if ((NS_FAILED(aURI->SchemeIs("http", &validScheme)) || !validScheme) &&
(NS_FAILED(aURI->SchemeIs("https", &validScheme)) || !validScheme) &&
(NS_FAILED(aURI->SchemeIs("ftp", &validScheme)) || !validScheme ) &&
(NS_FAILED(aURI->SchemeIs("gopher", &validScheme)) || !validScheme))
return NS_OK;
*aResult = nsnull;
nsCOMPtr<nsIIOService> ios = do_GetService(kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLCString scheme;
rv = aURI->GetScheme(getter_Copies(scheme));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIProtocolHandler> handler;
rv = ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
PRUint32 flags;
rv = handler->GetProtocolFlags(&flags);
if (NS_FAILED(rv)) return rv;
if (!(flags & nsIProtocolHandler::ALLOWS_PROXY))
return NS_OK; // Can't proxy this
// if proxies are enabled and this host:port combo is
// supposed to use a proxy, check for a proxy.
@ -351,93 +357,118 @@ nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, char * *aProxyHost, PRInt3
((1 == mUseProxy) && !CanUseProxy(aURI))) {
return NS_OK;
}
nsProxyInfo* proxyInfo = nsnull;
NS_NEWXPCOM(proxyInfo, nsProxyInfo);
if (!proxyInfo)
return NS_ERROR_OUT_OF_MEMORY;
// Proxy auto config magic...
if (2 == mUseProxy)
{
if (!mPAC) {
NS_ERROR("ERROR: PAC js component is null");
delete proxyInfo;
return NS_ERROR_NULL_POINTER;
}
rv = mPAC->ProxyForURL(aURI,
aProxyHost,
aProxyPort,
aProxyType);
if (NS_SUCCEEDED(rv)) {
if (*aProxyType == nsnull || !PL_strcasecmp("direct", *aProxyType)) {
if (*aProxyHost) {
nsMemory::Free(*aProxyHost);
*aProxyHost = nsnull;
}
if (*aProxyType) {
nsMemory::Free(*aProxyType);
*aProxyType = nsnull;
}
*aProxyPort = -1;
} else if (*aProxyPort <= 0) {
*aProxyPort = -1;
}
}
return rv;
&proxyInfo->mHost,
&proxyInfo->mPort,
&proxyInfo->mType);
if (NS_FAILED(rv) || !proxyInfo->Type() || // If: it didn't work
!PL_strcasecmp("direct", proxyInfo->Type()) || // OR we're meant to go direct
(PL_strcasecmp("http", proxyInfo->Type()) != 0 && // OR we're an http proxy...
!(flags & nsIProtocolHandler::ALLOWS_PROXY_HTTP))) { // ... but we can't proxy with http
delete proxyInfo; // don't proxy this
} else {
if (proxyInfo->Port() <= 0)
proxyInfo->mPort = -1;
NS_ADDREF(*aResult = proxyInfo);
}
return rv;
}
nsXPIDLCString scheme;
rv = aURI->GetScheme(getter_Copies(scheme));
if (NS_FAILED(rv)) return rv;
// Nothing below here returns failure
NS_ADDREF(*aResult = proxyInfo);
PRBool isScheme = PR_FALSE;
if (mHTTPProxyHost.get()[0] && mHTTPProxyPort > 0 &&
!PL_strcasecmp(scheme, "http")) {
*aProxyHost = PL_strdup(mHTTPProxyHost);
*aProxyType = PL_strdup("http");
*aProxyPort = mHTTPProxyPort;
NS_SUCCEEDED(aURI->SchemeIs("http", &isScheme)) && isScheme) {
proxyInfo->mHost = PL_strdup(mHTTPProxyHost);
proxyInfo->mType = PL_strdup("http");
proxyInfo->mPort = mHTTPProxyPort;
return NS_OK;
}
if (mHTTPSProxyHost.get()[0] && mHTTPSProxyPort > 0 &&
!PL_strcasecmp(scheme, "https")) {
*aProxyHost = PL_strdup(mHTTPSProxyHost);
*aProxyType = PL_strdup("http");
*aProxyPort = mHTTPSProxyPort;
NS_SUCCEEDED(aURI->SchemeIs("https", &isScheme)) && isScheme) {
proxyInfo->mHost = PL_strdup(mHTTPSProxyHost);
proxyInfo->mType = PL_strdup("http");
proxyInfo->mPort = mHTTPSProxyPort;
return NS_OK;
}
if (mFTPProxyHost.get()[0] && mFTPProxyPort > 0 &&
!PL_strcasecmp(scheme, "ftp")) {
*aProxyHost = PL_strdup(mFTPProxyHost);
*aProxyType = PL_strdup("http");
*aProxyPort = mFTPProxyPort;
NS_SUCCEEDED(aURI->SchemeIs("ftp", &isScheme)) && isScheme) {
proxyInfo->mHost = PL_strdup(mFTPProxyHost);
proxyInfo->mType = PL_strdup("http");
proxyInfo->mPort = mFTPProxyPort;
return NS_OK;
}
if (mGopherProxyHost.get()[0] && mGopherProxyPort > 0 &&
!PL_strcasecmp(scheme, "gopher")) {
*aProxyHost = PL_strdup(mGopherProxyHost);
*aProxyType = PL_strdup("http");
*aProxyPort = mGopherProxyPort;
NS_SUCCEEDED(aURI->SchemeIs("gopher", &isScheme)) && isScheme) {
proxyInfo->mHost = PL_strdup(mGopherProxyHost);
proxyInfo->mType = PL_strdup("http");
proxyInfo->mPort = mGopherProxyPort;
return NS_OK;
}
if (mSOCKSProxyHost.get()[0] && mSOCKSProxyPort > 0 &&
mSOCKSProxyVersion == 4) {
*aProxyHost = PL_strdup(mSOCKSProxyHost);
*aProxyPort = mSOCKSProxyPort;
*aProxyType = PL_strdup("socks4");
proxyInfo->mHost = PL_strdup(mSOCKSProxyHost);
proxyInfo->mPort = mSOCKSProxyPort;
proxyInfo->mType = PL_strdup("socks4");
return NS_OK;
}
if (mSOCKSProxyHost.get()[0] && mSOCKSProxyPort > 0 &&
mSOCKSProxyVersion == 5) {
*aProxyHost = PL_strdup(mSOCKSProxyHost);
*aProxyPort = mSOCKSProxyPort;
*aProxyType = PL_strdup("socks");
proxyInfo->mHost = PL_strdup(mSOCKSProxyHost);
proxyInfo->mPort = mSOCKSProxyPort;
proxyInfo->mType = PL_strdup("socks");
return NS_OK;
}
NS_RELEASE(*aResult); // Will call destructor
return NS_OK;
}
NS_IMETHODIMP
nsProtocolProxyService::NewProxyInfo(const char* type, const char* host,
PRInt32 port, nsIProxyInfo* *result)
{
nsProxyInfo* proxyInfo = nsnull;
NS_NEWXPCOM(proxyInfo, nsProxyInfo);
if (!proxyInfo)
return NS_ERROR_OUT_OF_MEMORY;
if (type)
proxyInfo->mType = nsCRT::strdup(type);
if (host)
proxyInfo->mHost = nsCRT::strdup(host);
proxyInfo->mPort = port;
*result = proxyInfo;
NS_ADDREF(*result);
return NS_OK;
}
NS_IMETHODIMP
nsProtocolProxyService::ConfigureFromPAC(const char *url)
{
@ -612,4 +643,3 @@ nsProtocolProxyService::LoadFilters(const char* filters)
np = endproxy;
}
}

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

@ -31,6 +31,8 @@
#include "nsXPIDLString.h"
#include "nsIProtocolProxyService.h"
#include "nsIProxyAutoConfig.h"
#include "nsIProxyInfo.h"
#include "prmem.h"
class nsProtocolProxyService : public nsIProtocolProxyService {
public:
@ -47,6 +49,35 @@ public:
void PrefsChanged(const char* pref);
class nsProxyInfo : public nsIProxyInfo {
NS_DECL_ISUPPORTS
NS_IMETHOD_(const char*) Host() {
return mHost;
}
NS_IMETHOD_(PRInt32) Port() {
return mPort;
}
NS_IMETHOD_(const char*) Type() {
return mType;
}
virtual ~nsProxyInfo() {
PR_FREEIF(mHost);
PR_FREEIF(mType);
}
nsProxyInfo() : mType(nsnull), mHost(nsnull), mPort(-1) {
NS_INIT_REFCNT();
}
char* mType;
char* mHost;
PRInt32 mPort;
};
protected:
void LoadFilters(const char* filters);

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

@ -103,7 +103,6 @@ nsProxyAutoConfig.prototype = {
},
onStopRequest: function(request, ctxt, status, errorMsg) {
this.done = true;
if(!ProxySandBox) {
ProxySandBox = new Sandbox();
}
@ -120,6 +119,7 @@ nsProxyAutoConfig.prototype = {
}
ProxySandBox.dnsResolve = dnsResolve;
LocalFindProxyForURL=ProxySandBox.FindProxyForURL;
this.done = true;
},
onDataAvailable: function(request, ctxt, inStream, sourceOffset, count) {

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

@ -44,6 +44,7 @@
#include "nsISSLSocketControl.h"
#include "nsITransportSecurityInfo.h"
#include "nsMemory.h"
#include "nsIProxyInfo.h"
#if defined(PR_LOGGING)
static PRLogModuleInfo *gSocketTransportLog = nsnull;
@ -127,13 +128,12 @@ nsSocketTransport::nsSocketTransport():
mSocketConnectTimeout(PR_MillisecondsToInterval(DEFAULT_SOCKET_CONNECT_TIMEOUT_IN_MS)),
mCurrentState(eSocketState_Created),
mHostName(nsnull),
mPort(0),
mPort(-1),
mMonitor(nsnull),
mOperation(eSocketOperation_None),
mProxyPort(0),
mProxyPort(-1),
mProxyHost(nsnull),
mProxyTransparent(PR_FALSE),
mSSLProxy(PR_FALSE),
mClosePending(PR_FALSE),
mWasConnected(PR_FALSE),
mService(nsnull),
@ -229,8 +229,7 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
PRInt32 aPort,
PRUint32 aSocketTypeCount,
const char* *aSocketTypes,
const char* aProxyHost,
PRInt32 aProxyPort,
nsIProxyInfo* aProxyInfo,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
@ -245,7 +244,8 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
NS_ADDREF(mService);
mPort = aPort;
mProxyPort = aProxyPort;
if (aProxyInfo)
mProxyPort = aProxyInfo->Port();
if (aHost && *aHost) {
mHostName = nsCRT::strdup(aHost);
@ -255,13 +255,20 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
else // hostname was nsnull or empty...
rv = NS_ERROR_FAILURE;
if (aProxyHost && *aProxyHost) {
mProxyHost = nsCRT::strdup(aProxyHost);
if (aProxyInfo && aProxyInfo->Host()) {
mProxyHost = nsCRT::strdup(aProxyInfo->Host());
if (!mProxyHost)
rv = NS_ERROR_OUT_OF_MEMORY;
}
if (NS_SUCCEEDED(rv) && aSocketTypeCount) {
if (NS_SUCCEEDED(rv) && (aSocketTypeCount || aProxyInfo)) {
const char* proxyType = nsnull;
if (aProxyInfo && nsCRT::strcmp(aProxyInfo->Type(), "http") != 0) {
proxyType = aProxyInfo->Type();
++aSocketTypeCount;
}
mSocketTypes = (char**) nsMemory::Alloc(aSocketTypeCount * sizeof(char*));
if (!mSocketTypes)
rv = NS_ERROR_OUT_OF_MEMORY;
@ -272,8 +279,17 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
return rv;
nsCOMPtr<nsISocketProvider> provider;
for (PRUint32 type = 0; type < aSocketTypeCount; type++) {
const char * socketType = aSocketTypes[type];
for (PRUint32 type = 0, pos = 0; pos < aSocketTypeCount; ++type, ++pos) {
const char * socketType = nsnull;
// Push a transport layer proxy if we have one
if (proxyType) {
socketType = proxyType;
} else {
socketType = aSocketTypes[type];
}
if (socketType == nsnull)
continue;
#ifdef DEBUG
@ -304,8 +320,12 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
// the default proxy behavior
mProxyTransparent = PR_TRUE;
}
if (mProxyHost && (nsCRT::strcmp(socketType, "ssl") == 0))
mSSLProxy = PR_TRUE;
// then go back to normal
if (proxyType) {
--type;
proxyType = nsnull;
}
}
}
}
@ -858,7 +878,7 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags)
"rv = %x.\n\n",
mHostName, mPort, this, rv));
if (rv == NS_OK && mSecurityInfo && mProxyHost && mProxyHost && proxyTransparent) {
if (rv == NS_OK && mSecurityInfo && mProxyHost && proxyTransparent) {
// if the connection phase is finished, and the ssl layer
// has been pushed, and we were proxying (transparently; ie. nothing
// has to happen in the protocol layer above us), it's time

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

@ -124,7 +124,7 @@ class nsSocketOS; // output stream
class nsSocketRequest;
class nsSocketReadRequest;
class nsSocketWriteRequest;
class nsIProxyInfo;
class nsSocketTransport : public nsISocketTransport,
public nsIDNSListener
@ -144,8 +144,7 @@ public:
PRInt32 aPort,
PRUint32 aSocketTypeCount,
const char* *aSocketTypes,
const char* aProxyHost,
PRInt32 aProxyPort,
nsIProxyInfo* aProxyInfo,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
@ -239,7 +238,6 @@ protected:
PRInt32 mProxyPort;
char* mProxyHost;
PRPackedBool mProxyTransparent;
PRPackedBool mSSLProxy;
/* put all the packed bools together so we save space */
PRPackedBool mClosePending;

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

@ -30,6 +30,7 @@
#include "nsProxiedService.h"
#include "nsString.h"
#include "nsNetCID.h"
#include "nsProtocolProxyService.h"
#ifdef DEBUG
// in debug builds this will be valid while the socket transport service is active.
@ -541,13 +542,12 @@ nsSocketTransportService::Run(void)
NS_IMETHODIMP
nsSocketTransportService::CreateTransport(const char* aHost,
PRInt32 aPort,
const char* proxyHost,
PRInt32 proxyPort,
nsIProxyInfo* proxyInfo,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsITransport** aResult)
{
return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyHost, proxyPort,
return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyInfo,
bufferSegmentSize, bufferMaxSize, aResult);
}
@ -555,14 +555,13 @@ NS_IMETHODIMP
nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
const char* aHost,
PRInt32 aPort,
const char* proxyHost,
PRInt32 proxyPort,
nsIProxyInfo* proxyInfo,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsITransport** aResult)
{
const char * types[] = { aSocketType };
return CreateTransportOfTypes(1, types, aHost, aPort, proxyHost, proxyPort,
return CreateTransportOfTypes(1, types, aHost, aPort, proxyInfo,
bufferSegmentSize, bufferMaxSize, aResult);
}
@ -571,8 +570,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount,
const char* *aSocketTypes,
const char* aHost,
PRInt32 aPort,
const char* proxyHost,
PRInt32 proxyPort,
nsIProxyInfo* aProxyInfo,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsITransport** aResult)
@ -597,21 +595,20 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount,
// Create and initialize a new connection object...
NS_NEWXPCOM(transport, nsSocketTransport);
if (transport) {
rv = transport->Init(this, aHost, aPort, socketTypeCount, aSocketTypes,
proxyHost, proxyPort, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
delete transport;
transport = nsnull;
}
}
else {
rv = NS_ERROR_OUT_OF_MEMORY;
rv = transport->Init(this, aHost, aPort, socketTypeCount, aSocketTypes,
aProxyInfo, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
delete transport;
transport = nsnull;
}
} else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
// Set the reference count to one...
if (NS_SUCCEEDED(rv)) {
NS_ADDREF(transport);
}
if (NS_SUCCEEDED(rv))
NS_ADDREF(transport);
*aResult = transport;
return rv;

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

@ -92,7 +92,7 @@ nsAboutProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetURIType(PRInt16 *result)
nsAboutProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;

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

@ -75,7 +75,7 @@ nsDataHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsDataHandler::GetURIType(PRInt16 *result) {
nsDataHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}

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

@ -33,8 +33,6 @@
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
// nsDateTimeChannel methods
nsDateTimeChannel::nsDateTimeChannel() {
NS_INIT_REFCNT();
@ -52,13 +50,14 @@ NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
nsIRequestObserver)
nsresult
nsDateTimeChannel::Init(nsIURI* uri)
nsDateTimeChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
rv = mUrl->GetPort(&mPort);
if (NS_FAILED(rv) || mPort < 1)
@ -163,12 +162,17 @@ nsDateTimeChannel::Open(nsIInputStream **_retval)
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
@ -185,12 +189,17 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
@ -334,4 +343,3 @@ nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
mContentLength = aLength;
return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength);
}

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

@ -38,7 +38,7 @@
#include "nsIURI.h"
#include "nsDateTimeHandler.h"
#include "nsIStreamListener.h"
#include "nsIProxyInfo.h"
class nsDateTimeChannel
: public nsIChannel,
@ -59,7 +59,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
@ -70,7 +70,8 @@ protected:
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCString mContentType;
PRInt32 mContentLength;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
PRInt32 mPort;
nsXPIDLCString mHost;

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

@ -43,7 +43,9 @@ nsDateTimeHandler::nsDateTimeHandler() {
nsDateTimeHandler::~nsDateTimeHandler() {
}
NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler)
NS_IMPL_ISUPPORTS2(nsDateTimeHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
@ -74,8 +76,8 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsDateTimeHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
nsDateTimeHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
@ -104,6 +106,13 @@ nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_IMETHODIMP
nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsDateTimeHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
@ -111,7 +120,7 @@ nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url);
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -26,7 +26,7 @@
#ifndef nsDateTimeHandler_h___
#define nsDateTimeHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
#define DATETIME_PORT 13
@ -34,11 +34,12 @@
#define NS_DATETIMEHANDLER_CID \
{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
class nsDateTimeHandler : public nsIProtocolHandler
class nsDateTimeHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsDateTimeHandler methods:
nsDateTimeHandler();

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

@ -97,7 +97,7 @@ nsFileProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsFileProtocolHandler::GetURIType(PRInt16 *result)
nsFileProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NOAUTH;
return NS_OK;

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

@ -62,7 +62,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
nsIRequestObserver)
nsresult
nsFingerChannel::Init(nsIURI* uri)
nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
nsXPIDLCString autoBuffer;
@ -70,6 +70,7 @@ nsFingerChannel::Init(nsIURI* uri)
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
// For security reasons, we do not allow the user to specify a
// non-default port for finger: URL's.
@ -197,7 +198,7 @@ nsFingerChannel::Open(nsIInputStream **_retval)
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;
@ -220,7 +221,7 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;

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

@ -35,6 +35,7 @@
#include "nsFingerHandler.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIProxyInfo.h"
class nsFingerChannel
: public nsIChannel,
@ -55,7 +56,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
@ -80,6 +81,7 @@ protected:
nsCOMPtr<nsISupports> mResponseContext;
nsCOMPtr<nsITransport> mTransport;
nsCOMPtr<nsIRequest> mTransportRequest;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsresult mStatus;
protected:

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

@ -43,7 +43,9 @@ nsFingerHandler::nsFingerHandler() {
nsFingerHandler::~nsFingerHandler() {
}
NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler)
NS_IMPL_ISUPPORTS2(nsFingerHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
@ -74,8 +76,8 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsFingerHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
nsFingerHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
@ -104,6 +106,13 @@ nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_IMETHODIMP
nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsFingerHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
@ -111,7 +120,7 @@ nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url);
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -26,7 +26,9 @@
#ifndef nsFingerHandler_h___
#define nsFingerHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
class nsIProxyInfo;
#define FINGER_PORT 79
@ -35,11 +37,12 @@
{ 0x76d6d5d8, 0x1dd2, 0x11b2, \
{0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} }
class nsFingerHandler : public nsIProtocolHandler
class nsFingerHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsFingerHandler methods:
nsFingerHandler();

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

@ -97,12 +97,13 @@ NS_IMPL_THREADSAFE_ISUPPORTS9(nsFTPChannel,
nsICacheListener);
nsresult
nsFTPChannel::Init(nsIURI* uri, nsICacheSession* session)
nsFTPChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo, nsICacheSession* session)
{
nsresult rv = NS_OK;
// setup channel state
mURL = uri;
mProxyInfo = proxyInfo;
rv = mURL->GetHost(getter_Copies(mHost));
if (NS_FAILED(rv)) return rv;
@ -327,7 +328,8 @@ nsFTPChannel::SetupState()
mPrompter,
mAuthPrompter,
mFTPEventSink,
mCacheEntry);
mCacheEntry,
mProxyInfo);
if (NS_FAILED(rv)) return rv;
(void) mFTPState->SetWriteStream(mUploadStream);

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

@ -44,6 +44,7 @@
#include "nsIAuthPrompt.h"
#include "nsIFTPChannel.h"
#include "nsIUploadChannel.h"
#include "nsIProxyInfo.h"
#include "nsICacheService.h"
#include "nsICacheEntryDescriptor.h"
@ -86,7 +87,9 @@ public:
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
// initializes the channel.
nsresult Init(nsIURI* uri, nsICacheSession* session);
nsresult Init(nsIURI* uri,
nsIProxyInfo* proxyInfo,
nsICacheSession* session);
nsresult SetupState();
nsresult GenerateCacheKey(nsACString &cacheKey);
@ -129,7 +132,7 @@ protected:
nsCOMPtr<nsICacheSession> mCacheSession;
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
};
#endif /* nsFTPChannel_h___ */

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

@ -543,7 +543,7 @@ nsFtpState::EstablishControlConnection()
// if we succeed, return. Otherwise, we need to
// create a transport
rv = mControlConnection->Connect();
rv = mControlConnection->Connect(mProxyInfo);
if (NS_SUCCEEDED(rv))
return rv;
}
@ -572,7 +572,7 @@ nsFtpState::EstablishControlConnection()
// Must do it this way 'cuz the channel intercepts the progress notifications.
(void) mControlConnection->SetStreamListener(NS_STATIC_CAST(nsIStreamListener*, this));
return mControlConnection->Connect();
return mControlConnection->Connect(mProxyInfo);
}
void
@ -1463,10 +1463,10 @@ nsFtpState::R_pasv() {
// now we know where to connect our data channel
nsCOMPtr<nsISocketTransportService> sts = do_GetService(kSocketTransportServiceCID, &rv);
rv = sts->CreateTransport(hostStr,
port,
nsnull, -1,
mProxyInfo,
FTP_DATA_CHANNEL_SEG_SIZE,
FTP_DATA_CHANNEL_MAX_SIZE,
getter_AddRefs(mDPipe)); // the data channel
@ -1676,7 +1676,8 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
nsIPrompt* aPrompter,
nsIAuthPrompt* aAuthPrompter,
nsIFTPEventSink* sink,
nsICacheEntryDescriptor* cacheEntry)
nsICacheEntryDescriptor* cacheEntry,
nsIProxyInfo* proxyInfo)
{
nsresult rv = NS_OK;
@ -1685,6 +1686,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
mFTPEventSink = sink;
mAuthPrompter = aAuthPrompter;
mCacheEntry = cacheEntry;
mProxyInfo = proxyInfo;
// parameter validation
NS_ASSERTION(aChannel, "FTP: needs a channel");
@ -1918,6 +1920,7 @@ nsFtpState::StopProcessing() {
mPrompter = 0;
mAuthPrompter = 0;
mChannel = 0;
mProxyInfo = 0;
return NS_OK;
}

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

@ -43,6 +43,7 @@
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
#include "nsITransport.h"
#include "nsIProxyInfo.h"
#include "nsFtpControlConnection.h"
@ -98,7 +99,8 @@ public:
nsIPrompt *aPrompter,
nsIAuthPrompt *aAuthPrompter,
nsIFTPEventSink *sink,
nsICacheEntryDescriptor* cacheEntry);
nsICacheEntryDescriptor* cacheEntry,
nsIProxyInfo* proxyInfo);
// use this to provide a stream to be written to the server.
nsresult SetWriteStream(nsIInputStream* aInStream);
@ -162,6 +164,7 @@ private:
// ****** consumer vars
nsCOMPtr<nsIFTPChannel> mChannel; // our owning FTP channel we pass through our events
nsCOMPtr<nsIProxyInfo> mProxyInfo;
// ****** connection cache vars
PRInt32 mServerType; // What kind of server are we talking to

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

@ -126,7 +126,7 @@ nsFtpControlConnection::IsAlive()
return isAlive;
}
nsresult
nsFtpControlConnection::Connect()
nsFtpControlConnection::Connect(nsIProxyInfo* proxyInfo)
{
nsresult rv;
@ -134,9 +134,10 @@ nsFtpControlConnection::Connect()
nsCOMPtr<nsITransport> transport;
// build our own
nsCOMPtr<nsISocketTransportService> sts = do_GetService(kSocketTransportServiceCID, &rv);
rv = sts->CreateTransport(mHost,
mPort,
nsnull, -1,
proxyInfo,
FTP_COMMAND_CHANNEL_SEG_SIZE,
FTP_COMMAND_CHANNEL_MAX_SIZE,
getter_AddRefs(mCPipe)); // the command transport

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

@ -33,6 +33,8 @@
#include "nsIOutputStream.h"
#include "nsAutoLock.h"
class nsIProxyInfo;
class nsFtpControlConnection : public nsIStreamListener
{
public:
@ -43,7 +45,7 @@ public:
nsFtpControlConnection(const char* host, PRUint32 port);
virtual ~nsFtpControlConnection();
nsresult Connect();
nsresult Connect(nsIProxyInfo* proxyInfo);
nsresult Disconnect(nsresult status);
nsresult Write(nsCString& command, PRBool suspend);

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

@ -88,7 +88,9 @@ nsFtpProtocolHandler::~nsFtpProtocolHandler() {
mIOSvc = 0;
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsFtpProtocolHandler, nsIProtocolHandler);
NS_IMPL_THREADSAFE_ISUPPORTS2(nsFtpProtocolHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler);
nsresult
nsFtpProtocolHandler::Init() {
@ -138,9 +140,9 @@ nsFtpProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsFtpProtocolHandler::GetURIType(PRInt16 *result)
nsFtpProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
*result = URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP;
return NS_OK;
}
@ -162,6 +164,12 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_IMETHODIMP
nsFtpProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsFtpProtocolHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, nsIChannel* *result)
{
nsresult rv = NS_OK;
@ -179,7 +187,7 @@ nsFtpProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result)
if (mCacheSession)
rv = mCacheSession->SetDoomEntriesIfExpired(PR_TRUE);
rv = channel->Init(url, mCacheSession);
rv = channel->Init(url, proxyInfo, mCacheSession);
if (NS_FAILED(rv)) {
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFtpProtocolHandler::NewChannel() FAILED\n"));
return rv;

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

@ -24,7 +24,7 @@
#define nsFtpProtocolHandler_h___
#include "nsIServiceManager.h"
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
#include "nsHashtable.h"
#include "nsIIOService.h"
#include "nsIThreadPool.h"
@ -36,10 +36,11 @@
#define NS_FTPPROTOCOLHANDLER_CID \
{ 0x25029490, 0xf132, 0x11d2, { 0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95 } }
class nsFtpProtocolHandler : public nsIProtocolHandler{
class nsFtpProtocolHandler : public nsIProxiedProtocolHandler {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsFtpProtocolHandler methods:
nsFtpProtocolHandler();

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

@ -75,7 +75,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsGopherChannel,
nsIRequestObserver);
nsresult
nsGopherChannel::Init(nsIURI* uri)
nsGopherChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
@ -84,6 +84,7 @@ nsGopherChannel::Init(nsIURI* uri)
return NS_ERROR_MALFORMED_URI;
mUrl = uri;
mProxyInfo = proxyInfo;
nsXPIDLCString buffer;
@ -244,8 +245,7 @@ nsGopherChannel::Open(nsIInputStream **_retval)
rv = socketService->CreateTransport(mHost,
mPort,
nsnull,
-1,
mProxyInfo,
BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE,
getter_AddRefs(mTransport));
@ -284,8 +284,7 @@ nsGopherChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
rv = socketService->CreateTransport(mHost,
mPort,
nsnull,
-1,
mProxyInfo,
BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE,
getter_AddRefs(mTransport));
@ -634,4 +633,4 @@ nsGopherChannel::SendRequest(nsITransport* aTransport)
0, mRequest.Length(), 0,
this, nsnull);
return rv;
}
}

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

@ -38,6 +38,7 @@
#include "nsIProxy.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIProxyInfo.h"
class nsGopherChannel : public nsIChannel,
public nsIStreamListener {
@ -56,7 +57,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIURI> mOriginalURI;
@ -82,6 +83,7 @@ protected:
nsCOMPtr<nsISupports> mResponseContext;
nsCOMPtr<nsITransport> mTransport;
nsCOMPtr<nsIRequest> mTransportRequest;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsresult mStatus;
nsresult SendRequest(nsITransport* aTransport);

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

@ -61,7 +61,9 @@ nsGopherHandler::~nsGopherHandler() {
PR_LOG(gGopherLog, PR_LOG_ALWAYS, ("~nsGopherHandler() called"));
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsGopherHandler, nsIProtocolHandler);
NS_IMPL_THREADSAFE_ISUPPORTS2(nsGopherHandler,
nsIProxiedProtocolHandler,
nsIProtocolHandler);
NS_METHOD
nsGopherHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
@ -91,8 +93,8 @@ nsGopherHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsGopherHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE;
nsGopherHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | ALLOWS_PROXY | ALLOWS_PROXY_HTTP;
return NS_OK;
}
@ -117,7 +119,8 @@ nsGopherHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
}
NS_IMETHODIMP
nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result)
nsGopherHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
nsGopherChannel* channel;
@ -125,7 +128,7 @@ nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result)
(void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url);
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
return rv;
}
@ -134,6 +137,12 @@ nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result)
return rv;
}
NS_IMETHODIMP
nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsGopherHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{

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

@ -23,7 +23,7 @@
#ifndef nsGopherHandler_h___
#define nsGopherHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIProxiedProtocolHandler.h"
#include "nsIProtocolProxyService.h"
#include "nsString.h"
#include "nsCOMPtr.h"
@ -36,10 +36,11 @@
{ 0x44588c1f, 0x2ce8, 0x4ad8, \
{0x9b, 0x16, 0xdf, 0xb9, 0xd9, 0xd5, 0x13, 0xa7} }
class nsGopherHandler : public nsIProtocolHandler {
class nsGopherHandler : public nsIProxiedProtocolHandler {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsGopherHandler methods:
nsGopherHandler();

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

@ -22,24 +22,11 @@
* Darin Fisher <darin@netscape.com>
*/
#include "nsIProtocolHandler.idl"
#include "nsIProxiedProtocolHandler.idl"
[scriptable, uuid(122c91c0-2485-40ba-89c9-b895934921bc)]
interface nsIHttpProtocolHandler : nsIProtocolHandler
interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler
{
/**
* Constructs a new http proxy channel.
*
* @param uri - the desired request-URI (eg. ftp://ftp.mozilla.org/)
* @param proxyHost - the proxy hostname
* @param proxyPort - the proxy port
* @param proxyType - the proxy type (usually "http" or "socks")
*/
nsIChannel newProxyChannel(in nsIURI uri,
in string proxyHost,
in long proxyPort,
in string proxyType);
/**
* Get the HTTP advertised user agent string.
*/

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

@ -103,9 +103,7 @@ nsHttpChannel::~nsHttpChannel()
nsresult
nsHttpChannel::Init(nsIURI *uri,
PRUint8 caps,
const char *proxyHost,
PRInt32 proxyPort,
const char *proxyType)
nsIProxyInfo *proxyInfo)
{
nsresult rv;
@ -141,8 +139,7 @@ nsHttpChannel::Init(nsIURI *uri,
LOG(("host=%s port=%d\n", host.get(), port));
mConnectionInfo = new nsHttpConnectionInfo(host, port,
proxyHost, proxyPort,
proxyType, usingSSL);
proxyInfo, usingSSL);
if (!mConnectionInfo)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mConnectionInfo);
@ -172,10 +169,10 @@ nsHttpChannel::Init(nsIURI *uri,
rv = mRequestHead.SetHeader(nsHttp::Host, hostLine);
if (NS_FAILED(rv)) return rv;
PRBool useProxy = (proxyHost && !PL_strcmp(proxyType, "http"));
rv = nsHttpHandler::get()->AddStandardRequestHeaders(&mRequestHead.Headers(),
caps, useProxy);
rv = nsHttpHandler::get()->
AddStandardRequestHeaders(&mRequestHead.Headers(),
caps,
mConnectionInfo->UsingHttpProxy());
if (NS_FAILED(rv)) return rv;
// check to see if authorization headers should be included
@ -300,13 +297,11 @@ nsHttpChannel::SetupTransaction()
NS_ADDREF(mTransaction);
// use the URI path if not proxying (transparent proxying such as SSL proxy
// or socks does not count here).
// does not count here).
nsXPIDLCString requestURIStr;
const char* requestURI;
if (!mConnectionInfo->ProxyHost() ||
mConnectionInfo->UsingSSL() ||
!PL_strcmp(mConnectionInfo->ProxyType(), "socks") ||
!PL_strcmp(mConnectionInfo->ProxyType(), "socks4")) {
if (mConnectionInfo->UsingSSL() ||
!mConnectionInfo->UsingHttpProxy()) {
rv = mURI->GetPath(getter_Copies(requestURIStr));
if (NS_FAILED(rv)) return rv;
requestURI = requestURIStr.get();
@ -1055,10 +1050,12 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
else
proxyPort = 80;
nsCOMPtr<nsIProxyInfo> pi;
rv = NS_NewProxyInfo("http", location, proxyPort, getter_AddRefs(pi));
// talk to the http handler directly for this case
rv = nsHttpHandler::get()->
NewProxyChannel(mURI, location, proxyPort, "http",
getter_AddRefs(newChannel));
NewProxiedChannel(mURI, pi, getter_AddRefs(newChannel));
if (NS_FAILED(rv)) return rv;
}
else {
@ -1509,8 +1506,7 @@ nsHttpChannel::AddAuthorizationHeaders()
// check if proxy credentials should be sent
const char *proxyHost = mConnectionInfo->ProxyHost();
const char *proxyType = mConnectionInfo->ProxyType();
if (proxyHost && !PL_strcmp(proxyType, "http")) {
if (proxyHost) {
rv = authCache->GetCredentialsForPath(proxyHost,
mConnectionInfo->ProxyPort(),
nsnull, realm, creds);

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

@ -42,11 +42,12 @@
#include "nsIUploadChannel.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsHttpConnection.h"
class nsHttpTransaction;
class nsHttpConnectionInfo;
class nsHttpResponseHead;
class nsIHttpAuthenticator;
class nsIProxyInfo;
//-----------------------------------------------------------------------------
// nsHttpChannel
@ -78,9 +79,7 @@ public:
nsresult Init(nsIURI *uri,
PRUint8 capabilities,
const char *proxyHost=0,
PRInt32 proxyPort=-1,
const char *proxyType=0);
nsIProxyInfo* proxyInfo);
private:
nsresult Connect(PRBool firstTime = PR_TRUE);

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

@ -354,11 +354,8 @@ nsHttpConnection::ActivateConnection()
if (NS_FAILED(rv)) return rv;
// need to handle SSL proxy CONNECT if this is the first time.
// unless its SOCKS.
if (mConnectionInfo->UsingSSL() &&
mConnectionInfo->ProxyHost() &&
PL_strcmp(mConnectionInfo->ProxyType(), "socks") &&
PL_strcmp(mConnectionInfo->ProxyType(), "socks4")) {
mConnectionInfo->UsingHttpProxy()) {
rv = SetupSSLProxyConnect();
if (NS_FAILED(rv)) return rv;
}
@ -458,33 +455,23 @@ nsHttpConnection::CreateTransport()
if (NS_FAILED(rv)) return rv;
// configure the socket type based on the connection type requested.
const char *types[3] = {0,0,0};
PRUint32 count = 0;
if (!PL_strcasecmp(mConnectionInfo->ProxyType(), "socks")) {
types[count] = "socks";
count++;
}
if (!PL_strcasecmp(mConnectionInfo->ProxyType(), "socks4")) {
types[count] = "socks4";
count++;
}
const char* type = nsnull;
if (mConnectionInfo->UsingSSL()) {
types[count] = "ssl";
count++;
if (mConnectionInfo->UsingHttpProxy())
type = "tlsstepup";
else
type = "ssl";
}
nsCOMPtr<nsITransport> transport;
rv = sts->CreateTransportOfTypes(count, types,
mConnectionInfo->Host(),
mConnectionInfo->Port(),
mConnectionInfo->ProxyHost(),
mConnectionInfo->ProxyPort(),
NS_HTTP_SEGMENT_SIZE,
NS_HTTP_BUFFER_SIZE,
getter_AddRefs(transport));
rv = sts->CreateTransportOfType(type,
mConnectionInfo->Host(),
mConnectionInfo->Port(),
mConnectionInfo->ProxyInfo(),
NS_HTTP_SEGMENT_SIZE,
NS_HTTP_BUFFER_SIZE,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
// the transport has better be a socket transport !!

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

@ -33,6 +33,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIEventQueue.h"
#include "nsIInputStream.h"
#include "nsIProxyInfo.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "plstr.h"
@ -148,20 +149,17 @@ class nsHttpConnectionInfo : public nsISupports
public:
NS_DECL_ISUPPORTS
nsHttpConnectionInfo(const char *host, PRInt32 port=-1,
const char *proxyHost=0, PRInt32 proxyPort=-1,
const char *proxyType=0, PRBool usingSSL=0)
: mProxyPort(proxyPort)
, mUsingSSL(usingSSL)
nsHttpConnectionInfo(const char *host, PRInt32 port,
nsIProxyInfo* proxyInfo,
PRBool usingSSL=PR_FALSE)
: mProxyInfo(proxyInfo)
, mUsingSSL(usingSSL)
{
LOG(("Creating nsHttpConnectionInfo @%x\n", this));
NS_INIT_ISUPPORTS();
if (proxyHost)
mProxyHost.Adopt(nsCRT::strdup(proxyHost));
if (proxyType)
mProxyType.Adopt(nsCRT::strdup(proxyType));
mUsingHttpProxy = (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http"));
SetOriginServer(host, port);
}
@ -170,7 +168,7 @@ public:
{
if (host)
mHost.Adopt(nsCRT::strdup(host));
mPort = port == -1 ? DefaultPort(): port;
mPort = port == -1 ? DefaultPort() : port;
return NS_OK;
}
@ -180,36 +178,40 @@ public:
LOG(("Destroying nsHttpConnectionInfo @%x\n", this));
}
const char *ProxyHost() const { return mProxyInfo ? mProxyInfo->Host() : nsnull; }
PRInt32 ProxyPort() const { return mProxyInfo ? mProxyInfo->Port() : -1; }
const char *ProxyType() const { return mProxyInfo ? mProxyInfo->Type() : nsnull; }
// Compare this connection info to another...
// Two connections are 'equal' if they end up talking the same
// protocol to the same server. This is needed to properly manage
// persistent connections to proxies
// Note that we don't care about transparent proxies -
// it doesn't matter if we're talking via socks or not, since
// a request will end up at the same host.
PRBool Equals(const nsHttpConnectionInfo *info)
{
// if its a host independent proxy, then compare the proxy
// servers.
if ((info->mProxyHost.get() || mProxyHost.get()) &&
!mUsingSSL &&
PL_strcasecmp(mProxyType, "socks") != 0 &&
PL_strcasecmp(mProxyType, "socks4") != 0) {
return (!PL_strcasecmp(info->mProxyHost, mProxyHost) &&
!PL_strcasecmp(info->mProxyType, mProxyType) &&
info->mProxyPort == mProxyPort &&
info->mUsingSSL == mUsingSSL);
}
// Strictly speaking, we could talk to a proxy on the same port
// and reuse the connection. Its not worth the extra strcmp.
if ((info->mUsingHttpProxy != mUsingHttpProxy) ||
(info->mUsingSSL != mUsingSSL))
return PR_FALSE;
// if its a proxy, then compare the proxy servers.
if (mUsingHttpProxy && !mUsingSSL)
return (!PL_strcasecmp(info->ProxyHost(), ProxyHost()) &&
info->ProxyPort() == ProxyPort());
// otherwise, just check the hosts
return (!PL_strcasecmp(info->mHost, mHost) &&
info->mPort == mPort &&
info->mUsingSSL == mUsingSSL);
info->mPort == mPort);
}
const char *Host() { return mHost; }
PRInt32 Port() { return mPort; }
const char *ProxyHost() { return mProxyHost; }
PRInt32 ProxyPort() { return mProxyPort; }
const char *ProxyType() { return mProxyType; }
nsIProxyInfo *ProxyInfo() { return mProxyInfo; }
PRBool UsingHttpProxy() { return mUsingHttpProxy; }
PRBool UsingSSL() { return mUsingSSL; }
PRInt32 DefaultPort() { return mUsingSSL ? 443 : 80; }
@ -217,9 +219,8 @@ public:
private:
nsXPIDLCString mHost;
PRInt32 mPort;
nsXPIDLCString mProxyHost;
PRInt32 mProxyPort;
nsXPIDLCString mProxyType;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
PRPackedBool mUsingHttpProxy;
PRPackedBool mUsingSSL;
};

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

@ -1519,8 +1519,9 @@ nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings)
// nsHttpHandler::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_THREADSAFE_ISUPPORTS4(nsHttpHandler,
NS_IMPL_THREADSAFE_ISUPPORTS5(nsHttpHandler,
nsIHttpProtocolHandler,
nsIProxiedProtocolHandler,
nsIProtocolHandler,
nsIObserver,
nsISupportsWeakReference)
@ -1542,9 +1543,9 @@ nsHttpHandler::GetDefaultPort(PRInt32 *aDefaultPort)
}
NS_IMETHODIMP
nsHttpHandler::GetURIType(PRInt16 *result)
nsHttpHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
*result = URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP;
return NS_OK;
}
@ -1587,11 +1588,9 @@ nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result)
}
}
rv = NewProxyChannel(uri,
nsnull,
-1,
nsnull,
result);
rv = NewProxiedChannel(uri,
nsnull,
result);
return rv;
}
@ -1604,20 +1603,18 @@ nsHttpHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
}
//-----------------------------------------------------------------------------
// nsHttpHandler::nsIHttpProtocolHandler
// nsHttpHandler::nsIProxiedProtocolHandler
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpHandler::NewProxyChannel(nsIURI *uri,
const char *proxyHost,
PRInt32 proxyPort,
const char *proxyType,
nsIChannel **result)
nsHttpHandler::NewProxiedChannel(nsIURI *uri,
nsIProxyInfo* proxyInfo,
nsIChannel **result)
{
nsHttpChannel *httpChannel = nsnull;
LOG(("nsHttpHandler::NewProxyChannel [proxy=%s:%d type=%s]\n",
proxyHost, proxyPort, proxyType));
LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n",
proxyInfo));
NS_NEWXPCOM(httpChannel, nsHttpChannel);
if (!httpChannel)
@ -1626,9 +1623,7 @@ nsHttpHandler::NewProxyChannel(nsIURI *uri,
nsresult rv = httpChannel->Init(uri,
mCapabilities,
proxyHost,
proxyPort,
proxyType);
proxyInfo);
if (NS_SUCCEEDED(rv))
rv = httpChannel->
@ -1638,6 +1633,10 @@ nsHttpHandler::NewProxyChannel(nsIURI *uri,
return rv;
}
//-----------------------------------------------------------------------------
// nsHttpHandler::nsIHttpProtocolHandler
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpHandler::GetUserAgent(char **aUserAgent)
{

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

@ -61,6 +61,7 @@ class nsHttpHandler : public nsIHttpProtocolHandler
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
NS_DECL_NSIHTTPPROTOCOLHANDLER
NS_DECL_NSIOBSERVER

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

@ -112,7 +112,7 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsJARProtocolHandler::GetURIType(PRInt16 *result)
nsJARProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
/* Although jar uris have their own concept of relative urls

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

@ -96,7 +96,7 @@ nsKeywordProtocolHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsKeywordProtocolHandler::GetURIType(PRInt16 *result) {
nsKeywordProtocolHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}

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

@ -167,7 +167,7 @@ nsResProtocolHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsResProtocolHandler::GetURIType(PRInt16 *result)
nsResProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
return NS_OK;

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

@ -121,7 +121,7 @@ nsThemeHandler::GetDefaultPort(PRInt32 *result)
}
NS_IMETHODIMP
nsThemeHandler::GetURIType(PRInt16 *result)
nsThemeHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;

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

@ -74,7 +74,7 @@ nsViewSourceHandler::GetDefaultPort(PRInt32 *result) {
}
NS_IMETHODIMP
nsViewSourceHandler::GetURIType(PRInt16 *result) {
nsViewSourceHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}

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

@ -32,7 +32,6 @@ REQUIRES = xpcom string necko nkcache timer cookie dbm util
SHARED_LIBRARY_LIBS = $(DIST)/lib/libmozdbm_s.$(LIB_SUFFIX)
CPPSRCS = \
TestOverlappedIO.cpp \
TestSocketIO.cpp \
TestSocketInput.cpp \
TestSocketTransport.cpp \

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

@ -311,7 +311,7 @@ main(int argc, char* argv[])
// Create the socket transport...
nsCOMPtr<nsITransport> transport;
rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, getter_AddRefs(transport));
rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, getter_AddRefs(transport));
if (NS_FAILED(rv)) {
NS_WARNING("failed to create: socket transport!");
return rv;

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

@ -163,7 +163,7 @@ main(int argc, char* argv[])
nsITransport* transport;
rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, &transport);
rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, &transport);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIRequest> request;
transport->AsyncRead(nsnull, new InputTestConsumer, 0, -1, 0, getter_AddRefs(request));

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

@ -305,7 +305,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
nsCOMPtr<nsISocketTransportService> sts =
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = sts->CreateTransport(aHostName, aPort, nsnull, -1, 0, 0, &mTransport);
rv = sts->CreateTransport(aHostName, aPort, nsnull, 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.

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

@ -525,7 +525,7 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetURIType(PRInt16 *result)
nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD;
return NS_OK;

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

@ -302,7 +302,7 @@ PRBool nsExternalProtocolHandler::HaveProtocolHandler(nsIURI * aURI)
return haveHandler;
}
NS_IMETHODIMP nsExternalProtocolHandler::GetURIType(PRInt16 *aUritype)
NS_IMETHODIMP nsExternalProtocolHandler::GetProtocolFlags(PRUint32 *aUritype)
{
// Make it norelative since it is a simple uri
*aUritype = URI_NORELATIVE;

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

@ -781,6 +781,8 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
nsresult err;
char buffer[8*1024];
PRUint32 writeCount;
printf("nsXPInstallManager::OnDataAvailable\n");
if (mCancelled)
{