This commit is contained in:
darin%netscape.com 2001-03-07 00:55:43 +00:00
Родитель afc2e22878
Коммит 4d82f129fb
4 изменённых файлов: 132 добавлений и 97 удалений

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

@ -81,34 +81,31 @@ extern PRLogModuleInfo* gHTTPLog;
#define LOG(args) PR_LOG(gHTTPLog, PR_LOG_DEBUG, args)
nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, nsHTTPHandler* i_Handler):
mResponse(nsnull),
mHandler(dont_QueryInterface(i_Handler)),
mRequest(nsnull),
mHTTPServerListener(nsnull),
mResponseContext(nsnull),
mCachedResponse(nsnull),
mURI(dont_QueryInterface(i_URL)),
mConnected(PR_FALSE),
mState(HS_IDLE),
mLoadAttributes(LOAD_NORMAL),
mLoadGroup(nsnull),
mCachedContentIsAvailable(PR_FALSE),
mCachedContentIsValid(PR_FALSE),
mFiredOnHeadersAvailable(PR_FALSE),
mFiredOpenOnStartRequest(PR_FALSE),
mFiredOpenOnStopRequest(PR_FALSE),
mAuthTriedWithPrehost(PR_FALSE),
mAuthRealm(nsnull),
mProxy(0),
mProxyPort(-1),
mProxyType(nsnull),
mProxyTransparent(PR_FALSE),
mStatus(NS_OK),
mPipeliningAllowed(PR_TRUE),
mPipelinedRequest(nsnull),
mApplyConversion(PR_TRUE),
mOpenHasEventQueue(PR_TRUE)
nsHTTPChannel::nsHTTPChannel(nsIURI *aURL, nsHTTPHandler *aHandler)
: mHandler(dont_QueryInterface(aHandler))
, mState(HS_IDLE)
, mStatus(NS_OK)
, mRequest(nsnull)
, mResponse(nsnull)
, mCachedResponse(nsnull)
, mHTTPServerListener(nsnull)
, mURI(dont_QueryInterface(aURL))
, mLoadAttributes(LOAD_NORMAL)
, mLoadGroup(nsnull)
, mAuthRealm(nsnull)
, mProxyType(nsnull)
, mProxy(nsnull)
, mProxyPort(-1)
, mPipelinedRequest(nsnull)
, mPipeliningAllowed(PR_TRUE)
, mConnected(PR_FALSE)
, mApplyConversion(PR_TRUE)
, mOpenHasEventQueue(PR_TRUE)
, mCachedContentIsAvailable(PR_FALSE)
, mCachedContentIsValid(PR_FALSE)
, mFiredOnHeadersAvailable(PR_FALSE)
, mAuthTriedWithPrehost(PR_FALSE)
, mProxyTransparent(PR_FALSE)
{
NS_INIT_ISUPPORTS();

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

@ -41,17 +41,22 @@
#include "nsHTTPResponseListener.h"
#include "nsIStreamListener.h"
#include "nsIStreamObserver.h"
#include "nsICachedNetData.h"
#include "nsIProxy.h"
#include "nsIPrompt.h"
#include "nsIHTTPEventSink.h"
#ifdef MOZ_NEW_CACHE
#include "nsICachingChannel.h"
#else
#include "nsIStreamAsFile.h"
#include "nsICachedNetData.h"
class nsICachedNetData;
#endif
class nsIFile;
class nsHTTPRequest;
class nsHTTPResponse;
class nsICachedNetData;
#define LOOPING_REDIRECT_ERROR_URI "chrome://necko/content/redirect_loop.xul"
@ -73,7 +78,11 @@ class nsHTTPChannel : public nsIHTTPChannel,
public nsIInterfaceRequestor,
public nsIProgressEventSink,
public nsIProxy,
#ifdef MOZ_NEW_CACHE
public nsICachingChannel
#else
public nsIStreamAsFile
#endif
{
public:
@ -90,7 +99,11 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIPROGRESSEVENTSINK
NS_DECL_NSIPROXY
#ifdef MOZ_NEW_CACHE
NS_DECL_NSICACHINGCHANNEL
#else
NS_DECL_NSISTREAMASFILE
#endif
// nsHTTPChannel methods:
nsresult Authenticate(const char *iChallenge,
@ -105,9 +118,6 @@ public:
nsresult SetResponse(nsHTTPResponse* i_pResp);
nsresult GetResponseContext(nsISupports** aContext);
nsresult CacheReceivedResponse(nsIStreamListener *aListener,
nsIStreamListener* *aResult);
nsresult CacheAbort(PRUint32 statusCode);
nsresult OnHeadersAvailable();
@ -115,7 +125,7 @@ public:
nsresult Abort();
PRUint32 getChannelState ();
PRUint32 getChannelState();
nsresult ReportProgress(PRUint32 aProgress,
PRUint32 aProgressMax);
@ -123,88 +133,117 @@ public:
nsresult BuildNotificationProxies ();
protected:
nsresult CacheReceivedResponse(nsIStreamListener *aListener,
nsIStreamListener* *aResult);
nsresult CacheAbort(PRUint32 statusCode);
nsresult CheckCache();
nsresult ReadFromCache();
nsresult ProcessStatusCode();
nsresult ProcessRedirection(PRInt32 aStatusCode);
nsresult ProcessAuthentication(PRInt32 aStatusCode);
nsresult ProcessNotModifiedResponse(nsIStreamListener *aListener);
public:
nsHTTPResponse* mResponse;
nsHTTPHandler* mHandler;
nsHTTPRequest* mRequest;
nsHTTPResponseListener* mHTTPServerListener;
nsCOMPtr<nsISupports> mResponseContext;
nsHTTPResponse* mCachedResponse;
nsCOMPtr<nsIProgressEventSink> mProgressEventSink;
nsCOMPtr<nsIProgressEventSink> mRealProgressEventSink;
nsISupports *ResponseContext() { return mResponseContext; }
void SetHTTPServerListener(nsHTTPResponseListener *l) { mHTTPServerListener = l; }
PRBool HasCachedResponse() { return mCachedResponse != 0; }
protected:
// for PUT/POST cases...
nsCOMPtr<nsIInputStream> mRequestStream;
nsCOMPtr<nsIStreamObserver> mWriteObserver;
nsHTTPHandler *mHandler;
HTTPState mState;
nsresult mStatus;
nsHTTPRequest *mRequest;
nsHTTPResponse *mResponse;
nsHTTPResponse *mCachedResponse;
nsHTTPResponseListener *mHTTPServerListener;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mReferrer;
// Various event sinks
nsCOMPtr<nsIHTTPEventSink> mEventSink;
nsCOMPtr<nsIHTTPEventSink> mRealEventSink;
PRBool mConnected;
HTTPState mState;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIPrompt> mRealPrompter;
nsCOMPtr<nsIProgressEventSink> mProgressEventSink;
nsCOMPtr<nsIProgressEventSink> mRealProgressEventSink;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIStreamListener> mResponseDataListener;
nsCOMPtr<nsIOutputStream> mBufOutputStream;
PRUint32 mLoadAttributes;
nsCOMPtr<nsILoadGroup> mLoadGroup;
// nsIPrincipal
nsCOMPtr<nsISupports> mOwner;
// SSL security info (copied from the transport)
nsCOMPtr<nsISupports> mSecurityInfo;
// Listener passed into AsyncOpen()
nsCOMPtr<nsIStreamListener> mResponseDataListener;
nsCOMPtr<nsISupports> mResponseContext;
// Pipe output stream used by Open()
nsCOMPtr<nsIOutputStream> mBufOutputStream;
// for PUT/POST cases...
nsCOMPtr<nsIInputStream> mRequestStream;
// Cache-related members
// Cache stuff
#ifdef MOZ_NEW_CACHE
nsCOMPtr<nsICacheSession> mCacheSession;
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
nsCOMPtr<nsITransport> mCacheTransport;
#else
nsCOMPtr<nsICachedNetData> mCacheEntry;
PRBool mCachedContentIsAvailable;
PRBool mCachedContentIsValid;
nsCOMPtr<nsIChannel> mCacheChannel;
nsCOMPtr<nsISupportsArray> mStreamAsFileObserverArray;
#endif
// The HTTP authentication realm (may be NULL)
char *mAuthRealm;
// Proxy stuff
char *mProxyType;
char *mProxy;
PRInt32 mProxyPort;
// Pipelining stuff
nsHTTPPipelinedRequest *mPipelinedRequest;
PRPackedBool mPipeliningAllowed;
// True if connected to a server
PRPackedBool mConnected;
// If this is true, then data should be decoded as we stream
// it to our listener
PRPackedBool mApplyConversion;
// If this is true, then we do not have to spawn a new thread
// to service Open()
PRPackedBool mOpenHasEventQueue;
// Cache-related flags
PRPackedBool mCachedContentIsAvailable;
PRPackedBool mCachedContentIsValid;
// Called OnHeadersAvailable()
PRBool mFiredOnHeadersAvailable;
PRPackedBool mFiredOnHeadersAvailable;
// Called mOpenObserver->OnStartRequest
PRBool mFiredOpenOnStartRequest;
PRBool mFiredOpenOnStopRequest;
// If this is true then we have already tried
// prehost as a response to the server challenge.
// And so we need to throw a dialog box!
PRPackedBool mAuthTriedWithPrehost;
// Auth related stuff-
/*
If this is true then we have already tried
prehost as a response to the server challenge.
And so we need to throw a dialog box!
*/
PRBool mAuthTriedWithPrehost;
char* mAuthRealm;
char* mProxy;
PRInt32 mProxyPort;
char* mProxyType;
// if the proxy doesn't affect the protocol behavior
// (such as socks) we want to reverse conditional proxy behavior
PRBool mProxyTransparent;
nsresult mStatus;
nsCOMPtr<nsIChannel> mCacheChannel;
PRBool mPipeliningAllowed;
nsHTTPPipelinedRequest* mPipelinedRequest;
nsCOMPtr<nsISupports> mSecurityInfo;
// Stream as file
nsCOMPtr<nsISupportsArray> mStreamAsFileObserverArray;
PRBool mApplyConversion;
PRBool mOpenHasEventQueue;
PRPackedBool mProxyTransparent;
};
#include "nsIRunnable.h"
@ -226,7 +265,7 @@ public:
protected:
nsCOMPtr<nsIChannel> mChannel;
nsCOMPtr<nsIStreamListener> mListener;
PRBool mProcessing;
PRPackedBool mProcessing;
};
#endif /* _nsHTTPChannel_h_ */

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

@ -1479,7 +1479,6 @@ nsHTTPHandler::PrefsChanged(const char* pref)
// general.useragent.override
if ((bChangedAll) || !PL_strcmp(pref, UA_PREF_PREFIX "override")) {
nsXPIDLCString uval;
nsresult rv = NS_OK;
rv = mPrefs->CopyCharPref(UA_PREF_PREFIX "override",
getter_Copies(uval));
if (NS_SUCCEEDED(rv)) {

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

@ -252,7 +252,7 @@ nsHTTPServerListener::nsHTTPServerListener(nsHTTPChannel *aChannel,
, mPipelinedRequest(request)
, mDoingProxySSLConnect(aDoingProxySSLConnect)
{
mChannel->mHTTPServerListener = this;
mChannel->SetHTTPServerListener(this);
nsRepository::CreateInstance(kSupportsVoidCID, NULL,
kSupportsVoidIID, getter_AddRefs(mChunkHeaderEOF));
@ -433,7 +433,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest *request,
if (NS_SUCCEEDED(rv1) && mResponseDataListener)
mResponseDataListener->OnDataAvailable(mChannel,
mChannel->mResponseContext, is, 0, mHeaderBuffer.Length());
mChannel->ResponseContext(), is, 0, mHeaderBuffer.Length());
mSimpleResponse = PR_FALSE;
}
@ -529,7 +529,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest *request,
}
rv = mResponseDataListener->OnDataAvailable(mChannel,
mChannel->mResponseContext,
mChannel->ResponseContext(),
i_pStream, 0, i_Length);
if (NS_FAILED(rv)) return rv;
@ -581,9 +581,9 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest *request,
if (mResponse)
mResponse->GetStatus(&status);
if (status != 304 || !mChannel->mCachedResponse) {
if (status != 304 || !mChannel->HasCachedResponse()) {
mChannel->ResponseCompleted(mResponseDataListener, NS_OK, nsnull);
mChannel->mHTTPServerListener = 0;
mChannel->SetHTTPServerListener(nsnull);
}
OnStartRequest(nsnull, nsnull);
@ -631,7 +631,7 @@ nsHTTPServerListener::OnStartRequest(nsIRequest* request, nsISupports* i_pContex
if (req) {
mChannel = req->mConnection;
if (mChannel) {
mChannel->mHTTPServerListener = this;
mChannel->SetHTTPServerListener(this);
NS_ADDREF(mChannel);
}
NS_RELEASE(req);
@ -692,9 +692,9 @@ nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext
if (mResponse)
mResponse->GetStatus(&status);
if (status != 304 || !mChannel->mCachedResponse) {
if (status != 304 || mChannel->HasCachedResponse()) {
mChannel->ResponseCompleted(mResponseDataListener, i_Status, aStatusArg);
mChannel->mHTTPServerListener = 0;
mChannel->SetHTTPServerListener(nsnull);
}
PRUint32 capabilities = 0;
@ -758,7 +758,7 @@ nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext
while (NS_SUCCEEDED(mPipelinedRequest->AdvanceToNextRequest())) {
OnStartRequest(nsnull, nsnull);
mChannel->ResponseCompleted(mResponseDataListener, i_Status, aStatusArg);
mChannel->mHTTPServerListener = 0;
mChannel->SetHTTPServerListener(nsnull);
}
mHandler->ReleasePipelinedRequest(mPipelinedRequest);
@ -810,7 +810,7 @@ nsresult nsHTTPServerListener::FireSingleOnData(nsIStreamListener *aListener,
if (mBytesReceived && mResponseDataListener) {
rv = mResponseDataListener->OnDataAvailable(mChannel,
mChannel->mResponseContext,
mChannel->ResponseContext(),
mDataStream, 0, mBytesReceived);
}
mDataStream = 0;
@ -1017,7 +1017,7 @@ nsHTTPServerListener::FinishedResponseHeaders()
// Fire the OnStartRequest notification - now that user data is available
//
if (NS_SUCCEEDED(rv) && mResponseDataListener) {
rv = mResponseDataListener->OnStartRequest(mChannel, mChannel->mResponseContext);
rv = mResponseDataListener->OnStartRequest(mChannel, mChannel->ResponseContext());
if (NS_FAILED(rv))
LOG(("\tOnStartRequest [this=%x]. Consumer failed! Status: %x\n", this, rv));
}