Code style consistency cleanup.

This commit is contained in:
gagan%netscape.com 1999-08-21 00:22:18 +00:00
Родитель f938373139
Коммит 0c214adc91
13 изменённых файлов: 277 добавлений и 277 удалений

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

@ -41,10 +41,10 @@ void ReplaceDotMess(char* io_Path);
class nsParsePath
{
public:
nsParsePath(nsStdURL* i_URL): m_URL(i_URL) {}
virtual ~nsParsePath() {m_URL->ParsePath();}
nsParsePath(nsStdURL* i_URL): mURL(i_URL) {}
virtual ~nsParsePath() {mURL->ParsePath();}
private:
nsStdURL* m_URL;
nsStdURL* mURL;
};
nsStdURL::nsStdURL(const char* i_Spec, nsISupports* outer)

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

@ -49,14 +49,14 @@ static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
nsIHTTPEventSink* i_HTTPEventSink,
nsHTTPHandler* i_Handler):
m_URI(dont_QueryInterface(i_URL)),
m_bConnected(PR_FALSE),
m_State(HS_IDLE),
mURI(dont_QueryInterface(i_URL)),
mConnected(PR_FALSE),
mState(HS_IDLE),
mRefCnt(0),
m_pHandler(dont_QueryInterface(i_Handler)),
m_pEventSink(dont_QueryInterface(i_HTTPEventSink)),
m_pResponse(nsnull),
m_pResponseDataListener(nsnull),
mHandler(dont_QueryInterface(i_Handler)),
mEventSink(dont_QueryInterface(i_HTTPEventSink)),
mResponse(nsnull),
mResponseDataListener(nsnull),
mLoadAttributes(LOAD_NORMAL),
mResponseContext(nsnull),
mLoadGroup(nsnull),
@ -75,11 +75,11 @@ nsHTTPChannel::~nsHTTPChannel()
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Deleting nsHTTPChannel [this=%x].\n", this));
//TODO if we keep our copy of m_URI, then delete it too.
NS_IF_RELEASE(m_pRequest);
NS_IF_RELEASE(m_pResponse);
//TODO if we keep our copy of mURI, then delete it too.
NS_IF_RELEASE(mRequest);
NS_IF_RELEASE(mResponse);
NS_IF_RELEASE(mPostStream);
NS_IF_RELEASE(m_pResponseDataListener);
NS_IF_RELEASE(mResponseDataListener);
NS_IF_RELEASE(mLoadGroup);
}
@ -112,8 +112,8 @@ nsHTTPChannel::IsPending(PRBool *result)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->IsPending(result);
if (mRequest) {
rv = mRequest->IsPending(result);
}
return rv;
}
@ -123,8 +123,8 @@ nsHTTPChannel::Cancel(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Cancel();
if (mRequest) {
rv = mRequest->Cancel();
}
return rv;
}
@ -134,8 +134,8 @@ nsHTTPChannel::Suspend(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Suspend();
if (mRequest) {
rv = mRequest->Suspend();
}
return rv;
}
@ -145,8 +145,8 @@ nsHTTPChannel::Resume(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Resume();
if (mRequest) {
rv = mRequest->Resume();
}
return rv;
}
@ -158,7 +158,7 @@ NS_IMETHODIMP
nsHTTPChannel::GetURI(nsIURI* *o_URL)
{
if (o_URL) {
*o_URL = m_URI;
*o_URL = mURI;
NS_IF_ADDREF(*o_URL);
return NS_OK;
} else {
@ -173,11 +173,11 @@ nsHTTPChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
#if 0
nsresult rv;
if (!m_bConnected)
if (!mConnected)
Open();
nsIInputStream* inStr; // this guy gets passed out to the user
rv = NS_NewSyncStreamListener(&m_pResponseDataListener, &inStr);
rv = NS_NewSyncStreamListener(&mResponseDataListener, &inStr);
if (NS_FAILED(rv)) return rv;
*o_Stream = inStr;
@ -185,8 +185,8 @@ nsHTTPChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
#else
if (m_pResponse)
return m_pResponse->GetInputStream(o_Stream);
if (mResponse)
return mResponse->GetInputStream(o_Stream);
NS_ERROR("No response!");
return NS_OK; // change to error ? or block till response is set up?
#endif // if 0
@ -207,7 +207,7 @@ nsHTTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
nsresult rv = NS_OK;
// Initial parameter checks...
if (m_pResponseDataListener) {
if (mResponseDataListener) {
rv = NS_ERROR_IN_PROGRESS;
}
else if (!listener) {
@ -216,8 +216,8 @@ nsHTTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
// Initiate the loading of the URL...
if (NS_SUCCEEDED(rv)) {
m_pResponseDataListener = listener;
NS_ADDREF(m_pResponseDataListener);
mResponseDataListener = listener;
NS_ADDREF(mResponseDataListener);
mResponseContext = aContext;
@ -281,7 +281,7 @@ nsHTTPChannel::GetContentType(char * *aContentType)
//
NS_WITH_SERVICE(nsIMIMEService, MIMEService, kMIMEServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = MIMEService->GetTypeFromURI(m_URI, aContentType);
rv = MIMEService->GetTypeFromURI(mURI, aContentType);
if (NS_SUCCEEDED(rv)) return rv;
// XXX we should probably set the content-type for this http response at this stage too.
}
@ -321,15 +321,15 @@ nsHTTPChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
NS_IMETHODIMP
nsHTTPChannel::GetRequestHeader(nsIAtom* i_Header, char* *o_Value)
{
NS_ASSERTION(m_pRequest, "The request object vanished from underneath the connection!");
return m_pRequest->GetHeader(i_Header, o_Value);
NS_ASSERTION(mRequest, "The request object vanished from underneath the connection!");
return mRequest->GetHeader(i_Header, o_Value);
}
NS_IMETHODIMP
nsHTTPChannel::SetRequestHeader(nsIAtom* i_Header, const char* i_Value)
{
NS_ASSERTION(m_pRequest, "The request object vanished from underneath the connection!");
return m_pRequest->SetHeader(i_Header, i_Value);
NS_ASSERTION(mRequest, "The request object vanished from underneath the connection!");
return mRequest->SetHeader(i_Header, i_Value);
}
NS_IMETHODIMP
@ -337,8 +337,8 @@ nsHTTPChannel::GetRequestHeaderEnumerator(nsISimpleEnumerator** aResult)
{
nsresult rv;
if (m_pRequest) {
rv = m_pRequest->GetHeaderEnumerator(aResult);
if (mRequest) {
rv = mRequest->GetHeaderEnumerator(aResult);
} else {
rv = NS_ERROR_FAILURE;
}
@ -349,10 +349,10 @@ nsHTTPChannel::GetRequestHeaderEnumerator(nsISimpleEnumerator** aResult)
NS_IMETHODIMP
nsHTTPChannel::GetResponseHeader(nsIAtom* i_Header, char* *o_Value)
{
if (!m_bConnected)
if (!mConnected)
Open();
if (m_pResponse)
return m_pResponse->GetHeader(i_Header, o_Value);
if (mResponse)
return mResponse->GetHeader(i_Header, o_Value);
else
return NS_ERROR_FAILURE ; // NS_ERROR_NO_RESPONSE_YET ?
}
@ -363,12 +363,12 @@ nsHTTPChannel::GetResponseHeaderEnumerator(nsISimpleEnumerator** aResult)
{
nsresult rv;
if (!m_bConnected) {
if (!mConnected) {
Open();
}
if (m_pResponse) {
rv = m_pResponse->GetHeaderEnumerator(aResult);
if (mResponse) {
rv = mResponse->GetHeaderEnumerator(aResult);
} else {
*aResult = nsnull;
rv = NS_ERROR_FAILURE ; // NS_ERROR_NO_RESPONSE_YET ?
@ -379,20 +379,20 @@ nsHTTPChannel::GetResponseHeaderEnumerator(nsISimpleEnumerator** aResult)
NS_IMETHODIMP
nsHTTPChannel::GetResponseStatus(PRUint32 *o_Status)
{
if (!m_bConnected)
if (!mConnected)
Open();
if (m_pResponse)
return m_pResponse->GetStatus(o_Status);
if (mResponse)
return mResponse->GetStatus(o_Status);
return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ?
}
NS_IMETHODIMP
nsHTTPChannel::GetResponseString(char* *o_String)
{
if (!m_bConnected)
if (!mConnected)
Open();
if (m_pResponse)
return m_pResponse->GetStatusString(o_String);
if (mResponse)
return mResponse->GetStatusString(o_String);
return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ?
}
@ -402,7 +402,7 @@ nsHTTPChannel::GetEventSink(nsIHTTPEventSink* *o_EventSink)
nsresult rv;
if (o_EventSink) {
*o_EventSink = m_pEventSink;
*o_EventSink = mEventSink;
NS_IF_ADDREF(*o_EventSink);
rv = NS_OK;
} else {
@ -415,8 +415,8 @@ nsHTTPChannel::GetEventSink(nsIHTTPEventSink* *o_EventSink)
NS_IMETHODIMP
nsHTTPChannel::SetRequestMethod(PRUint32/*HTTPMethod*/ i_Method)
{
NS_ASSERTION(m_pRequest, "No request set as yet!");
return m_pRequest ? m_pRequest->SetMethod((HTTPMethod)i_Method) : NS_ERROR_FAILURE;
NS_ASSERTION(mRequest, "No request set as yet!");
return mRequest ? mRequest->SetMethod((HTTPMethod)i_Method) : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -425,8 +425,8 @@ nsHTTPChannel::GetResponseDataListener(nsIStreamListener* *aListener)
nsresult rv = NS_OK;
if (aListener) {
*aListener = m_pResponseDataListener;
NS_IF_ADDREF(m_pResponseDataListener);
*aListener = mResponseDataListener;
NS_IF_ADDREF(mResponseDataListener);
} else {
rv = NS_ERROR_NULL_POINTER;
}
@ -456,11 +456,11 @@ nsHTTPChannel::Init()
*/
nsresult rv;
m_pRequest = new nsHTTPRequest(m_URI);
if (m_pRequest == nsnull)
mRequest = new nsHTTPRequest(mURI);
if (mRequest == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(m_pRequest);
m_pRequest->SetConnection(this);
NS_ADDREF(mRequest);
mRequest->SetConnection(this);
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
PRUnichar * ua = nsnull;
@ -470,7 +470,7 @@ nsHTTPChannel::Init()
nsCRT::free(ua);
char * uaCString = uaString.ToNewCString();
if (!uaCString) return NS_ERROR_OUT_OF_MEMORY;
m_pRequest->SetHeader(nsHTTPAtoms::User_Agent, uaCString);
mRequest->SetHeader(nsHTTPAtoms::User_Agent, uaCString);
nsCRT::free(uaCString);
return NS_OK;
}
@ -478,16 +478,16 @@ nsHTTPChannel::Init()
nsresult
nsHTTPChannel::Open(void)
{
if (m_bConnected || (m_State > HS_WAITING_FOR_OPEN))
if (mConnected || (mState > HS_WAITING_FOR_OPEN))
return NS_ERROR_ALREADY_CONNECTED;
// Set up a new request observer and a response listener and pass to the transport
nsresult rv = NS_OK;
nsCOMPtr<nsIChannel> channel;
rv = m_pHandler->RequestTransport(m_URI, this, getter_AddRefs(channel));
rv = mHandler->RequestTransport(mURI, this, getter_AddRefs(channel));
if (NS_ERROR_BUSY == rv) {
m_State = HS_WAITING_FOR_OPEN;
mState = HS_WAITING_FOR_OPEN;
return NS_OK;
}
@ -575,20 +575,20 @@ nsHTTPChannel::Open(void)
if (channel) {
nsCOMPtr<nsIInputStream> stream;
m_pRequest->SetTransport(channel);
mRequest->SetTransport(channel);
//Get the stream where it will read the request data from
rv = m_pRequest->GetInputStream(getter_AddRefs(stream));
rv = mRequest->GetInputStream(getter_AddRefs(stream));
if (NS_SUCCEEDED(rv) && stream) {
PRUint32 count;
// Write the request to the server...
rv = stream->GetLength(&count);
rv = channel->AsyncWrite(stream, 0, count, this , m_pRequest);
rv = channel->AsyncWrite(stream, 0, count, this , mRequest);
if (NS_FAILED(rv)) return rv;
m_State = HS_WAITING_FOR_RESPONSE;
m_bConnected = PR_TRUE;
mState = HS_WAITING_FOR_RESPONSE;
mConnected = PR_TRUE;
} else {
NS_ERROR("Failed to get request Input stream.");
return NS_ERROR_FAILURE;
@ -604,16 +604,16 @@ nsresult nsHTTPChannel::ResponseCompleted(nsIChannel* aTransport)
{
// Null out pointers that are no longer needed...
mResponseContext = null_nsCOMPtr();
NS_IF_RELEASE(m_pResponseDataListener);
NS_IF_RELEASE(mResponseDataListener);
return m_pHandler->ReleaseTransport(aTransport);
return mHandler->ReleaseTransport(aTransport);
}
nsresult nsHTTPChannel::SetResponse(nsHTTPResponse* i_pResp)
{
NS_IF_RELEASE(m_pResponse);
m_pResponse = i_pResp;
NS_IF_ADDREF(m_pResponse);
NS_IF_RELEASE(mResponse);
mResponse = i_pResp;
NS_IF_ADDREF(mResponse);
return NS_OK;
}

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

@ -107,14 +107,14 @@ public:
nsresult SetContentType(const char* aContentType);
protected:
nsCOMPtr<nsIURI> m_URI;
PRBool m_bConnected;
nsCOMPtr<nsHTTPHandler> m_pHandler;
HTTPState m_State;
nsCOMPtr<nsIHTTPEventSink> m_pEventSink;
nsHTTPRequest* m_pRequest;
nsHTTPResponse* m_pResponse;
nsIStreamListener* m_pResponseDataListener;
nsCOMPtr<nsIURI> mURI;
PRBool mConnected;
nsCOMPtr<nsHTTPHandler> mHandler;
HTTPState mState;
nsCOMPtr<nsIHTTPEventSink> mEventSink;
nsHTTPRequest* mRequest;
nsHTTPResponse* mResponse;
nsIStreamListener* mResponseDataListener;
PRUint32 mLoadAttributes;
nsCOMPtr<nsISupports> mResponseContext;

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

@ -87,7 +87,7 @@ nsHTTPHandler::nsHTTPHandler()
// Initialize the Atoms used by the HTTP protocol...
nsHTTPAtoms::AddRefAtoms();
rv = NS_NewISupportsArray(getter_AddRefs(m_pConnections));
rv = NS_NewISupportsArray(getter_AddRefs(mConnections));
if (NS_FAILED(rv)) {
NS_ERROR("unable to create new ISupportsArray");
}
@ -150,10 +150,10 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
PRInt32 index;
//Check to see if an instance already exists in the active list
m_pConnections->Count(&count);
mConnections->Count(&count);
for (index=count-1; index >= 0; --index) {
//switch to static_cast...
pChannel = (nsHTTPChannel*)((nsIHTTPChannel*) m_pConnections->ElementAt(index));
pChannel = (nsHTTPChannel*)((nsIHTTPChannel*) mConnections->ElementAt(index));
//Do other checks here as well... TODO
rv = pChannel->GetURI(getter_AddRefs(channelURI));
if (NS_SUCCEEDED(rv) && (channelURI.get() == i_URL))
@ -285,7 +285,7 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
NS_METHOD
nsHTTPHandler::FollowRedirects(PRBool bFollow)
{
//m_bFollowRedirects = bFollow;
//mFollowRedirects = bFollow;
return NS_OK;
}

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

@ -146,7 +146,7 @@ private:
// This is the array of connections that the handler thread maintains to
// verify unique requests.
nsCOMPtr<nsISupportsArray> m_pConnections;
nsCOMPtr<nsISupportsArray> mConnections;
nsCOMPtr<nsISupportsArray> mPendingChannelList;
nsCOMPtr<nsISupportsArray> mTransportList;
};

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

@ -71,16 +71,16 @@ nsHeaderEntry::GetValue(char ** aResult)
nsHTTPHeaderArray::nsHTTPHeaderArray()
{
(void)NS_NewISupportsArray(getter_AddRefs(m_pHTTPHeaders));
(void)NS_NewISupportsArray(getter_AddRefs(mHTTPHeaders));
}
nsHTTPHeaderArray::~nsHTTPHeaderArray()
{
if (m_pHTTPHeaders) {
m_pHTTPHeaders->Clear();
if (mHTTPHeaders) {
mHTTPHeaders->Clear();
}
m_pHTTPHeaders = null_nsCOMPtr();
mHTTPHeaders = null_nsCOMPtr();
}
@ -89,8 +89,8 @@ nsresult nsHTTPHeaderArray::SetHeader(nsIAtom* aHeader, const char* aValue)
nsHeaderEntry *entry = nsnull;
PRInt32 i;
NS_ASSERTION(m_pHTTPHeaders, "header array doesn't exist.");
if (!m_pHTTPHeaders) {
NS_ASSERTION(mHTTPHeaders, "header array doesn't exist.");
if (!mHTTPHeaders) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -100,7 +100,7 @@ nsresult nsHTTPHeaderArray::SetHeader(nsIAtom* aHeader, const char* aValue)
//
if (!aValue) {
if (entry) {
m_pHTTPHeaders->RemoveElementAt(i);
mHTTPHeaders->RemoveElementAt(i);
NS_RELEASE(entry);
}
return NS_OK;
@ -115,7 +115,7 @@ nsresult nsHTTPHeaderArray::SetHeader(nsIAtom* aHeader, const char* aValue)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(entry);
m_pHTTPHeaders->AppendElement(entry);
mHTTPHeaders->AppendElement(entry);
}
//
// Append the new value to the existing string
@ -141,8 +141,8 @@ nsresult nsHTTPHeaderArray::GetHeader(nsIAtom* aHeader, char* *aResult)
*aResult = nsnull;
NS_ASSERTION(m_pHTTPHeaders, "header array doesn't exist.");
if (!m_pHTTPHeaders) {
NS_ASSERTION(mHTTPHeaders, "header array doesn't exist.");
if (!mHTTPHeaders) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -166,12 +166,12 @@ PRInt32 nsHTTPHeaderArray::GetEntry(nsIAtom* aHeader, nsHeaderEntry** aResult)
*aResult = nsnull;
count = 0;
(void)m_pHTTPHeaders->Count(&count);
(void)mHTTPHeaders->Count(&count);
for (i = 0; i < count; i++) {
nsISupports *entry = nsnull;
nsHeaderEntry* element;
entry = m_pHTTPHeaders->ElementAt(i);
entry = mHTTPHeaders->ElementAt(i);
element = NS_STATIC_CAST(nsHeaderEntry*, entry);
if (aHeader == element->mAtom.get()) {
*aResult = element;
@ -188,12 +188,12 @@ nsresult nsHTTPHeaderArray::GetEnumerator(nsISimpleEnumerator** aResult)
nsresult rv = NS_OK;
nsISimpleEnumerator* enumerator;
NS_ASSERTION(m_pHTTPHeaders, "header array doesn't exist.");
if (!m_pHTTPHeaders) {
NS_ASSERTION(mHTTPHeaders, "header array doesn't exist.");
if (!mHTTPHeaders) {
return NS_ERROR_OUT_OF_MEMORY;
}
enumerator = new nsHTTPHeaderEnumerator(m_pHTTPHeaders);
enumerator = new nsHTTPHeaderEnumerator(mHTTPHeaders);
if (enumerator) {
NS_ADDREF(enumerator);
} else {

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

@ -61,7 +61,7 @@ protected:
PRBool IsHeaderMultiple(nsIAtom* aHeader);
protected:
nsCOMPtr<nsISupportsArray> m_pHTTPHeaders;
nsCOMPtr<nsISupportsArray> mHTTPHeaders;
};

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

@ -37,26 +37,26 @@ extern PRLogModuleInfo* gHTTPLog;
nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURL, HTTPMethod i_Method,
nsIChannel* i_pTransport):
m_Method(i_Method),
m_Version(HTTP_ONE_ZERO),
m_Request(nsnull)
mMethod(i_Method),
mVersion(HTTP_ONE_ZERO),
mRequest(nsnull)
{
NS_INIT_REFCNT();
m_pURI = do_QueryInterface(i_pURL);
mURI = do_QueryInterface(i_pURL);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Creating nsHTTPRequest [this=%x].\n", this));
m_pTransport = i_pTransport;
NS_IF_ADDREF(m_pTransport);
mTransport = i_pTransport;
NS_IF_ADDREF(mTransport);
// Send Host header by default
if (HTTP_ZERO_NINE != m_Version)
if (HTTP_ZERO_NINE != mVersion)
{
nsXPIDLCString host;
NS_ASSERTION(m_pURI, "No URI for the request!!");
m_pURI->GetHost(getter_Copies(host));
NS_ASSERTION(mURI, "No URI for the request!!");
mURI->GetHost(getter_Copies(host));
SetHeader(nsHTTPAtoms::Host, host);
}
}
@ -66,11 +66,11 @@ nsHTTPRequest::~nsHTTPRequest()
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Deleting nsHTTPRequest [this=%x].\n", this));
NS_IF_RELEASE(m_Request);
NS_IF_RELEASE(m_pTransport);
NS_IF_RELEASE(mRequest);
NS_IF_RELEASE(mTransport);
/*
if (m_pConnection)
NS_RELEASE(m_pConnection);
if (mConnection)
NS_RELEASE(mConnection);
*/
}
@ -109,8 +109,8 @@ nsHTTPRequest::IsPending(PRBool *result)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->IsPending(result);
if (mTransport) {
rv = mTransport->IsPending(result);
}
return rv;
}
@ -120,8 +120,8 @@ nsHTTPRequest::Cancel(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Cancel();
if (mTransport) {
rv = mTransport->Cancel();
}
return rv;
}
@ -131,8 +131,8 @@ nsHTTPRequest::Suspend(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Suspend();
if (mTransport) {
rv = mTransport->Suspend();
}
return rv;
}
@ -142,8 +142,8 @@ nsHTTPRequest::Resume(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Resume();
if (mTransport) {
rv = mTransport->Resume();
}
return rv;
}
@ -156,12 +156,12 @@ nsHTTPRequest::Build()
{
nsresult rv;
if (m_Request) {
if (mRequest) {
NS_ERROR("Request already built!");
return NS_ERROR_FAILURE;
}
if (!m_pURI) {
if (!mURI) {
NS_ERROR("No URL to build request for!");
return NS_ERROR_NULL_POINTER;
}
@ -172,7 +172,7 @@ nsHTTPRequest::Build()
NS_HTTP_REQUEST_BUFFER_SIZE, nsnull);
if (NS_FAILED(rv)) return rv;
rv = NS_NewBufferInputStream(&m_Request, buf);
rv = NS_NewBufferInputStream(&mRequest, buf);
if (NS_FAILED(rv)) return rv;
//
@ -187,9 +187,9 @@ nsHTTPRequest::Build()
this));
// Write the request method and HTTP version.
lineBuffer.Append(MethodToString(m_Method));
lineBuffer.Append(MethodToString(mMethod));
rv = m_pURI->GetPath(getter_Copies(autoBuffer));
rv = mURI->GetPath(getter_Copies(autoBuffer));
lineBuffer.Append(autoBuffer);
//Trim off the # portion if any...
@ -209,10 +209,10 @@ nsHTTPRequest::Build()
#endif
if (NS_FAILED(rv)) return rv;
/* switch (m_Method)
/* switch (mMethod)
{
case HM_GET:
PL_strncpy(lineBuffer, MethodToString(m_Method)
PL_strncpy(lineBuffer, MethodToString(mMethod)
break;
case HM_DELETE:
case HM_HEAD:
@ -271,8 +271,8 @@ nsHTTPRequest::Build()
}
nsCOMPtr<nsIInputStream> stream;
NS_ASSERTION(m_pConnection, "Hee ha!");
if (NS_FAILED(m_pConnection->GetPostDataStream(getter_AddRefs(stream))))
NS_ASSERTION(mConnection, "Hee ha!");
if (NS_FAILED(mConnection->GetPostDataStream(getter_AddRefs(stream))))
return NS_ERROR_FAILURE;
// Currently nsIPostStreamData contains the header info and the data.
@ -282,7 +282,7 @@ nsHTTPRequest::Build()
if (stream)
{
NS_ASSERTION(m_Method == HM_POST, "Post data without a POST method?");
NS_ASSERTION(mMethod == HM_POST, "Post data without a POST method?");
PRUint32 length;
stream->GetLength(&length);
@ -336,14 +336,14 @@ nsHTTPRequest::Clone(const nsHTTPRequest* *o_Request) const
NS_METHOD
nsHTTPRequest::SetMethod(HTTPMethod i_Method)
{
m_Method = i_Method;
mMethod = i_Method;
return NS_OK;
}
HTTPMethod
nsHTTPRequest::GetMethod(void) const
{
return m_Method;
return mMethod;
}
NS_METHOD
@ -375,14 +375,14 @@ nsHTTPRequest::GetHeader(nsIAtom* i_Header, char* *o_Value)
NS_METHOD
nsHTTPRequest::SetHTTPVersion(HTTPVersion i_Version)
{
m_Version = i_Version;
mVersion = i_Version;
return NS_OK;
}
NS_METHOD
nsHTTPRequest::GetHTTPVersion(HTTPVersion* o_Version)
{
*o_Version = m_Version;
*o_Version = mVersion;
return NS_OK;
}
@ -391,11 +391,11 @@ nsHTTPRequest::GetInputStream(nsIInputStream* *o_Stream)
{
if (o_Stream)
{
if (!m_Request)
if (!mRequest)
{
Build();
}
m_Request->QueryInterface(nsCOMTypeInfo<nsIInputStream>::GetIID(), (void**)o_Stream);
mRequest->QueryInterface(nsCOMTypeInfo<nsIInputStream>::GetIID(), (void**)o_Stream);
return NS_OK;
}
else
@ -428,10 +428,10 @@ nsHTTPRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext,
nsHTTPResponseListener* pListener;
//Prepare to receive the response!
pListener = new nsHTTPResponseListener(m_pConnection);
pListener = new nsHTTPResponseListener(mConnection);
if (pListener) {
NS_ADDREF(pListener);
rv = m_pTransport->AsyncRead(0, -1,
rv = mTransport->AsyncRead(0, -1,
i_pContext,
pListener);
NS_RELEASE(pListener);
@ -453,10 +453,10 @@ nsHTTPRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext,
"\tStatus: %x\n",
this, iStatus));
(void) m_pConnection->GetResponseContext(getter_AddRefs(consumerContext));
rv = m_pConnection->GetResponseDataListener(getter_AddRefs(consumer));
(void) mConnection->GetResponseContext(getter_AddRefs(consumerContext));
rv = mConnection->GetResponseDataListener(getter_AddRefs(consumer));
if (consumer) {
consumer->OnStopRequest(m_pConnection, consumerContext, iStatus, i_pMsg);
consumer->OnStopRequest(mConnection, consumerContext, iStatus, i_pMsg);
}
rv = iStatus;
@ -468,16 +468,16 @@ nsHTTPRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext,
NS_IMETHODIMP
nsHTTPRequest::SetTransport(nsIChannel* i_pTransport)
{
NS_ASSERTION(!m_pTransport, "Transport being overwritten!");
m_pTransport = i_pTransport;
NS_ADDREF(m_pTransport);
NS_ASSERTION(!mTransport, "Transport being overwritten!");
mTransport = i_pTransport;
NS_ADDREF(mTransport);
return NS_OK;
}
NS_IMETHODIMP
nsHTTPRequest::SetConnection(nsHTTPChannel* i_pConnection)
{
m_pConnection = i_pConnection;
mConnection = i_pConnection;
return NS_OK;
}

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

@ -147,13 +147,13 @@ protected:
return methods[i_Method];
}
HTTPMethod m_Method;
nsCOMPtr<nsIURL> m_pURI;
HTTPVersion m_Version;
HTTPMethod mMethod;
nsCOMPtr<nsIURL> mURI;
HTTPVersion mVersion;
// The actual request stream!
nsIBufferInputStream* m_Request;
nsIChannel* m_pTransport;
nsHTTPChannel* m_pConnection;
nsIBufferInputStream* mRequest;
nsIChannel* mTransport;
nsHTTPChannel* mConnection;
nsHTTPHeaderArray mHeaders;
};

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

@ -26,24 +26,24 @@
#include "nsHTTPAtoms.h"
nsHTTPResponse::nsHTTPResponse(nsIInputStream* i_InputStream):
m_pStatusString(nsnull)
mStatusString(nsnull)
{
NS_INIT_REFCNT();
m_Status = 0;
m_ServerVersion = HTTP_ONE_ZERO;
mStatus = 0;
mServerVersion = HTTP_ONE_ZERO;
m_pInputStream = i_InputStream;
NS_IF_ADDREF(m_pInputStream);
mInputStream = i_InputStream;
NS_IF_ADDREF(mInputStream);
}
nsHTTPResponse::~nsHTTPResponse()
{
NS_IF_RELEASE(m_pInputStream);
NS_IF_RELEASE(mInputStream);
if (m_pStatusString) {
nsCRT::free(m_pStatusString);
m_pStatusString = nsnull;
if (mStatusString) {
nsCRT::free(mStatusString);
mStatusString = nsnull;
}
}
@ -71,7 +71,7 @@ nsresult nsHTTPResponse::GetContentLength(PRInt32* o_Value)
nsresult nsHTTPResponse::GetStatus(PRUint32* o_Value)
{
if (o_Value)
*o_Value = m_Status;
*o_Value = mStatus;
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
@ -80,7 +80,7 @@ nsresult nsHTTPResponse::GetStatus(PRUint32* o_Value)
nsresult nsHTTPResponse::GetStatusString(char* *o_String)
{
if (o_String)
*o_String = m_pStatusString;
*o_String = mStatusString;
return NS_OK;
}
@ -106,7 +106,7 @@ nsresult nsHTTPResponse::SetServerVersion(const char* i_Version)
{
// convert it to HTTP Version
// TODO
m_ServerVersion = HTTP_ONE_ZERO;
mServerVersion = HTTP_ONE_ZERO;
return NS_OK;
}
@ -115,9 +115,9 @@ nsresult nsHTTPResponse::SetStatusString(const char* i_Status)
{
nsresult rv = NS_OK;
NS_ASSERTION(!m_pStatusString, "Overwriting status string!");
m_pStatusString = nsCRT::strdup(i_Status);
if (!m_pStatusString) {
NS_ASSERTION(!mStatusString, "Overwriting status string!");
mStatusString = nsCRT::strdup(i_Status);
if (!mStatusString) {
rv = NS_ERROR_FAILURE;
}
@ -126,7 +126,7 @@ nsresult nsHTTPResponse::SetStatusString(const char* i_Status)
nsresult nsHTTPResponse::GetInputStream(nsIInputStream* *o_Stream)
{
*o_Stream = m_pInputStream;
*o_Stream = mInputStream;
return NS_OK;
}

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

@ -63,13 +63,13 @@ public:
protected:
NS_IMETHOD SetStatus(PRInt32 i_Value) { m_Status = i_Value; return NS_OK;};
NS_IMETHOD SetStatus(PRInt32 i_Value) { mStatus = i_Value; return NS_OK;};
NS_IMETHOD SetStatusString(const char* i_Value);
HTTPVersion m_ServerVersion;
char* m_pStatusString;
PRUint32 m_Status;
nsIInputStream* m_pInputStream;
HTTPVersion mServerVersion;
char* mStatusString;
PRUint32 mStatus;
nsIInputStream* mInputStream;
nsHTTPHeaderArray mHeaders;

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

@ -50,20 +50,20 @@ static const int kMAX_HEADER_SIZE = 60000;
nsHTTPResponseListener::nsHTTPResponseListener(nsHTTPChannel* aConnection):
m_bFirstLineParsed(PR_FALSE),
m_pResponse(nsnull),
m_pConsumer(nsnull),
m_ReadLength(0),
m_bHeadersDone(PR_FALSE),
m_HeaderBuffer(eOneByte),
m_ResponseContext(nsnull),
m_Channel(nsnull)
mFirstLineParsed(PR_FALSE),
mResponse(nsnull),
mConsumer(nsnull),
mReadLength(0),
mHeadersDone(PR_FALSE),
mHeaderBuffer(eOneByte),
mResponseContext(nsnull),
mChannel(nsnull)
{
NS_INIT_REFCNT();
NS_ASSERTION(aConnection, "HTTPChannel is null.");
m_pConnection = aConnection;
NS_IF_ADDREF(m_pConnection);
mConnection = aConnection;
NS_IF_ADDREF(mConnection);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Creating nsHTTPResponseListener [this=%x].\n", this));
@ -75,9 +75,9 @@ nsHTTPResponseListener::~nsHTTPResponseListener()
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Deleting nsHTTPResponseListener [this=%x].\n", this));
NS_IF_RELEASE(m_pConnection);
NS_IF_RELEASE(m_pResponse);
NS_IF_RELEASE(m_pConsumer);
NS_IF_RELEASE(mConnection);
NS_IF_RELEASE(mResponse);
NS_IF_RELEASE(mConsumer);
}
NS_IMPL_ISUPPORTS(nsHTTPResponseListener,nsCOMTypeInfo<nsIStreamListener>::GetIID());
@ -103,21 +103,21 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel,
"\tstream=%x. \toffset=%d. \tlength=%d.\n",
this, i_pStream, i_SourceOffset, i_Length));
if (!m_pResponse)
if (!mResponse)
{
// why do I need the connection in the constructor... get rid.. TODO
m_pResponse = new nsHTTPResponse (bufferInStream);
if (!m_pResponse) {
mResponse = new nsHTTPResponse (bufferInStream);
if (!mResponse) {
NS_ERROR("Failed to create the response object!");
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(m_pResponse);
m_pConnection->SetResponse(m_pResponse);
NS_ADDREF(mResponse);
mConnection->SetResponse(mResponse);
}
//
// Parse the status line and the response headers from the server
//
if (!m_bHeadersDone) {
if (!mHeadersDone) {
nsCOMPtr<nsIBuffer> pBuffer;
rv = bufferInStream->GetBuffer(getter_AddRefs(pBuffer));
@ -126,7 +126,7 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel,
// Parse the status line from the server. This is always the
// first line of the response...
//
if (!m_bFirstLineParsed) {
if (!mFirstLineParsed) {
rv = ParseStatusLine(pBuffer, i_Length, &actualBytesRead);
i_Length -= actualBytesRead;
}
@ -137,7 +137,7 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel,
// Parse the response headers as long as there is more data and
// the headers are not done...
//
while (NS_SUCCEEDED(rv) && i_Length && !m_bHeadersDone) {
while (NS_SUCCEEDED(rv) && i_Length && !mHeadersDone) {
rv = ParseHTTPHeader(pBuffer, i_Length, &actualBytesRead);
NS_ASSERTION(i_Length - actualBytesRead <= i_Length, "wrap around");
i_Length -= actualBytesRead;
@ -148,18 +148,18 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel,
// All the headers have been read. Check the status code of the
// response to see if any special action should be taken.
//
if (m_bHeadersDone) {
if (mHeadersDone) {
rv = FinishedResponseHeaders();
}
}
if (NS_SUCCEEDED(rv) && m_pConsumer) {
if (NS_SUCCEEDED(rv) && mConsumer) {
if (i_Length) {
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tOnDataAvailable [this=%x]. Calling consumer "
"OnDataAvailable.\tlength:%d\n", this, i_Length));
rv = m_pConsumer->OnDataAvailable(m_pConnection, m_ResponseContext, i_pStream, 0,
rv = mConsumer->OnDataAvailable(mConnection, mResponseContext, i_pStream, 0,
i_Length);
}
}
@ -177,13 +177,13 @@ nsHTTPResponseListener::OnStartRequest(nsIChannel* channel, nsISupports* i_pCont
("nsHTTPResponseListener::OnStartRequest [this=%x].\n", this));
// Initialize header varaibles...
m_bHeadersDone = PR_FALSE;
m_bFirstLineParsed = PR_FALSE;
mHeadersDone = PR_FALSE;
mFirstLineParsed = PR_FALSE;
// Cache the nsIStreamListener and ISupports context of the consumer...
rv = m_pConnection->GetResponseDataListener(&m_pConsumer);
rv = mConnection->GetResponseDataListener(&mConsumer);
if (NS_SUCCEEDED(rv)) {
rv = m_pConnection->GetResponseContext(getter_AddRefs(m_ResponseContext));
rv = mConnection->GetResponseContext(getter_AddRefs(mResponseContext));
}
return rv;
@ -200,7 +200,7 @@ nsHTTPResponseListener::OnStopRequest(nsIChannel* channel,
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("nsHTTPResponseListener::OnStopRequest [this=%x].\n", this));
if (NS_SUCCEEDED(rv) && !m_bHeadersDone) {
if (NS_SUCCEEDED(rv) && !mHeadersDone) {
//
// Oh great!! The server has closed the connection without sending
// an entity. Assume that it has sent all the response headers and
@ -209,31 +209,31 @@ nsHTTPResponseListener::OnStopRequest(nsIChannel* channel,
//
// Ignore the return code, since the request is being completed...
//
m_bHeadersDone = PR_TRUE;
if (m_pResponse) {
mHeadersDone = PR_TRUE;
if (mResponse) {
(void)FinishedResponseHeaders();
}
}
// Pass the notification out to the consumer...
if (m_pConsumer) {
rv = m_pConsumer->OnStopRequest(m_pConnection, m_ResponseContext, i_Status, i_pMsg);
if (mConsumer) {
rv = mConsumer->OnStopRequest(mConnection, mResponseContext, i_Status, i_pMsg);
}
// Notify the HTTPChannel that the response has completed...
NS_ASSERTION(m_pConnection, "HTTPChannel is null.");
if (m_pConnection) {
m_pConnection->ResponseCompleted(channel);
NS_ASSERTION(mConnection, "HTTPChannel is null.");
if (mConnection) {
mConnection->ResponseCompleted(channel);
}
// The Consumer is no longer needed...
NS_IF_RELEASE(m_pConsumer);
NS_IF_RELEASE(mConsumer);
// The HTTPChannel is no longer needed...
NS_IF_RELEASE(m_pConnection);
NS_IF_RELEASE(mConnection);
// The Response Context is no longer needed...
m_ResponseContext = nsnull;
mResponseContext = nsnull;
return rv;
}
@ -241,15 +241,15 @@ nsHTTPResponseListener::OnStopRequest(nsIChannel* channel,
nsresult nsHTTPResponseListener::FireOnHeadersAvailable()
{
nsresult rv;
NS_ASSERTION(m_bHeadersDone, "Headers have not been received!");
NS_ASSERTION(mHeadersDone, "Headers have not been received!");
if (m_bHeadersDone) {
if (mHeadersDone) {
// Notify the event sink that response headers are available...
nsCOMPtr<nsIHTTPEventSink> sink;
m_pConnection->GetEventSink(getter_AddRefs(sink));
mConnection->GetEventSink(getter_AddRefs(sink));
if (sink) {
sink->OnHeadersAvailable(m_pConnection);
sink->OnHeadersAvailable(mConnection);
}
// Check for any modules that want to receive headers once they've arrived.
@ -322,7 +322,7 @@ nsresult nsHTTPResponseListener::FireOnHeadersAvailable()
// send off the notification, and block.
// make the nsIHTTPNotify api call
pNotify->AsyncExamineResponse(m_pConnection);
pNotify->AsyncExamineResponse(mConnection);
NS_RELEASE(pNotify);
// we could do something with the return code from the external
// module, but what????
@ -372,7 +372,7 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBuffer* aBuffer,
*aBytesRead = 0;
if (kMAX_HEADER_SIZE < m_HeaderBuffer.Length()) {
if (kMAX_HEADER_SIZE < mHeaderBuffer.Length()) {
// This server is yanking our chain...
return NS_ERROR_FAILURE;
}
@ -393,7 +393,7 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBuffer* aBuffer,
}
rv = aBuffer->ReadSegments(nsWriteToString,
(void*)&m_HeaderBuffer,
(void*)&mHeaderBuffer,
totalBytesToRead,
&actualBytesRead);
if (NS_FAILED(rv)) return rv;
@ -405,14 +405,14 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBuffer* aBuffer,
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tParseStatusLine [this=%x].\tGot Status-Line:%s\n"
, this, m_HeaderBuffer.GetBuffer()));
, this, mHeaderBuffer.GetBuffer()));
//
// Replace all LWS with single SP characters. Also remove the CRLF
// characters...
//
m_HeaderBuffer.CompressSet(" \t", ' ');
m_HeaderBuffer.StripChars("\r\n");
mHeaderBuffer.CompressSet(" \t", ' ');
mHeaderBuffer.StripChars("\r\n");
//
// The Status Line has the following: format:
@ -427,28 +427,28 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBuffer* aBuffer,
// Parse the HTTP-Version:: "HTTP" "/" 1*DIGIT "." 1*DIGIT
//
offset = m_HeaderBuffer.Find(' ');
(void) m_HeaderBuffer.Left(str, offset);
offset = mHeaderBuffer.Find(' ');
(void) mHeaderBuffer.Left(str, offset);
if (!str.Length()) {
// The status line is bogus...
return NS_ERROR_FAILURE;
}
token = str.GetBuffer();
m_pResponse->SetServerVersion(token);
mResponse->SetServerVersion(token);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tParseStatusLine [this=%x].\tHTTP-Version: %s\n",
this, token));
m_HeaderBuffer.Cut(0, offset+1);
mHeaderBuffer.Cut(0, offset+1);
//
// Parse the Status-Code:: 3DIGIT
//
PRInt32 statusCode;
offset = m_HeaderBuffer.Find(' ');
(void) m_HeaderBuffer.Left(str, offset);
offset = mHeaderBuffer.Find(' ');
(void) mHeaderBuffer.Left(str, offset);
if (3 != str.Length()) {
// The status line is bogus...
return NS_ERROR_FAILURE;
@ -457,26 +457,26 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBuffer* aBuffer,
statusCode = str.ToInteger(&error);
if (NS_FAILED(error)) return NS_ERROR_FAILURE;
m_pResponse->SetStatus(statusCode);
mResponse->SetStatus(statusCode);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tParseStatusLine [this=%x].\tStatus-Code: %d\n",
this, statusCode));
m_HeaderBuffer.Cut(0, offset+1);
mHeaderBuffer.Cut(0, offset+1);
//
// Parse the Reason-Phrase:: *<TEXT excluding CR,LF>
//
token = m_HeaderBuffer.GetBuffer();
m_pResponse->SetStatusString(token);
token = mHeaderBuffer.GetBuffer();
mResponse->SetStatusString(token);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tParseStatusLine [this=%x].\tReason-Phrase: %s\n",
this, token));
m_HeaderBuffer.Truncate();
m_bFirstLineParsed = PR_TRUE;
mHeaderBuffer.Truncate();
mFirstLineParsed = PR_TRUE;
return rv;
}
@ -495,7 +495,7 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBuffer* aBuffer,
*aBytesRead = 0;
if (kMAX_HEADER_SIZE < m_HeaderBuffer.Length()) {
if (kMAX_HEADER_SIZE < mHeaderBuffer.Length()) {
// This server is yanking our chain...
return NS_ERROR_FAILURE;
}
@ -510,7 +510,7 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBuffer* aBuffer,
// If last character in the header string is a LF, then the header
// may be complete...
//
if (m_HeaderBuffer.Last() == '\n' ) {
if (mHeaderBuffer.Last() == '\n' ) {
rv = aBuffer->GetReadSegment(0, &buf, &actualBytesRead);
// Need to wait for more data to see if the header is complete.
if (0 == actualBytesRead) {
@ -540,7 +540,7 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBuffer* aBuffer,
// Append the buffer into the header string...
rv = aBuffer->ReadSegments(nsWriteToString,
(void*)&m_HeaderBuffer,
(void*)&mHeaderBuffer,
totalBytesToRead,
&actualBytesRead);
if (NS_FAILED(rv)) return rv;
@ -554,17 +554,17 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBuffer* aBuffer,
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("\tParseHTTPHeader [this=%x].\tGot header string:%s\n",
this, m_HeaderBuffer.GetBuffer()));
this, mHeaderBuffer.GetBuffer()));
//
// Replace all LWS with single SP characters. And remove all of the CRLF
// characters...
//
m_HeaderBuffer.CompressSet(" \t", ' ');
m_HeaderBuffer.StripChars("\r\n");
mHeaderBuffer.CompressSet(" \t", ' ');
mHeaderBuffer.StripChars("\r\n");
if (!m_HeaderBuffer.Length()) {
m_bHeadersDone = PR_TRUE;
if (!mHeaderBuffer.Length()) {
mHeadersDone = PR_TRUE;
return NS_OK;
}
@ -576,31 +576,31 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBuffer* aBuffer,
nsAutoString headerKey(eOneByte);
nsCOMPtr<nsIAtom> headerAtom;
colonOffset = m_HeaderBuffer.Find(':');
colonOffset = mHeaderBuffer.Find(':');
if (-1 == colonOffset) {
//
// The header is malformed... Just clear it.
//
m_HeaderBuffer.Truncate();
mHeaderBuffer.Truncate();
return NS_ERROR_FAILURE;
}
(void) m_HeaderBuffer.Left(headerKey, colonOffset);
(void) mHeaderBuffer.Left(headerKey, colonOffset);
headerKey.ToLowerCase();
//
// Extract the value field - everything past the ':'
// Trim any leading or trailing whitespace...
//
m_HeaderBuffer.Cut(0, colonOffset+1);
m_HeaderBuffer.Trim(" ");
mHeaderBuffer.Cut(0, colonOffset+1);
mHeaderBuffer.Trim(" ");
headerAtom = NS_NewAtom(headerKey.GetBuffer());
if (headerAtom) {
rv = ProcessHeader(headerAtom, m_HeaderBuffer);
rv = ProcessHeader(headerAtom, mHeaderBuffer);
} else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
m_HeaderBuffer.Truncate();
mHeaderBuffer.Truncate();
return rv;
}
@ -616,7 +616,7 @@ nsresult nsHTTPResponseListener::FinishedResponseHeaders(void)
//
// Check the status code to see if any special processing is necessary.
//
// If a redirect (ie. 30x) occurs, the m_pConsumer is released and a new
// If a redirect (ie. 30x) occurs, the mConsumer is released and a new
// request is issued...
//
rv = ProcessStatusCode();
@ -624,8 +624,8 @@ nsresult nsHTTPResponseListener::FinishedResponseHeaders(void)
//
// Fire the OnStartRequest notification - now that user data is available
//
if (NS_SUCCEEDED(rv) && m_pConsumer) {
rv = m_pConsumer->OnStartRequest(m_pConnection, m_ResponseContext);
if (NS_SUCCEEDED(rv) && mConsumer) {
rv = mConsumer->OnStartRequest(mConnection, mResponseContext);
if (NS_FAILED(rv)) return rv;
// Notify the consumer that headers are available...
@ -651,16 +651,16 @@ nsresult nsHTTPResponseListener::ProcessHeader(nsIAtom* aHeader,
semicolon = aValue.Find(';');
if (-1 != semicolon) {
aValue.Left(buffer, semicolon);
m_pConnection->SetContentType(buffer.GetBuffer());
mConnection->SetContentType(buffer.GetBuffer());
} else {
m_pConnection->SetContentType(aValue.GetBuffer());
mConnection->SetContentType(aValue.GetBuffer());
}
}
//
// Set the response header...
//
rv = m_pResponse->SetHeader(aHeader, aValue.GetBuffer());
rv = mResponse->SetHeader(aHeader, aValue.GetBuffer());
return rv;
}
@ -672,7 +672,7 @@ nsresult nsHTTPResponseListener::ProcessStatusCode(void)
PRUint32 statusCode, statusClass;
statusCode = 0;
rv = m_pResponse->GetStatus(&statusCode);
rv = mResponse->GetStatus(&statusCode);
statusClass = statusCode / 100;
@ -744,7 +744,7 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
char *location;
location = nsnull;
m_pResponse->GetHeader(nsHTTPAtoms::Location, &location);
mResponse->GetHeader(nsHTTPAtoms::Location, &location);
if ((301 == aStatusCode) || (302 == aStatusCode)) {
if (location) {
@ -761,7 +761,7 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
m_pConnection->GetURI(getter_AddRefs(baseURL));
mConnection->GetURI(getter_AddRefs(baseURL));
rv = serv->NewURI(location, baseURL, getter_AddRefs(newURL));
#endif
@ -778,22 +778,22 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
#endif /* PR_LOGGING */
#if 0
// Expanded inline to avoid linking with neckoutils.... (temporary)
rv = NS_OpenURI(m_pConsumer, m_ResponseContext, newURL);
rv = NS_OpenURI(mConsumer, mResponseContext, newURL);
#else
nsIChannel* channel;
rv = serv->NewChannelFromURI("load", newURL, nsnull, &channel);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILoadGroup> group;
rv = m_pConnection->GetLoadGroup(getter_AddRefs(group));
rv = mConnection->GetLoadGroup(getter_AddRefs(group));
if (group) {
// Add the new channel first. That way we don't run the risk
// of emptying the group and firing off the OnEndDocumentLoad
// notification.
(void)group->AddChannel(channel, m_ResponseContext);
(void)group->RemoveChannel(m_pConnection, m_ResponseContext,
(void)group->AddChannel(channel, mResponseContext);
(void)group->RemoveChannel(mConnection, mResponseContext,
aStatusCode, nsnull); // XXX error message
}
rv = channel->AsyncRead(0, -1, m_ResponseContext, m_pConsumer);
rv = channel->AsyncRead(0, -1, mResponseContext, mConsumer);
NS_RELEASE(channel);
}
#endif
@ -802,9 +802,9 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
//
// Fire the OnRedirect(...) notification.
//
m_pConnection->GetEventSink(getter_AddRefs(sink));
mConnection->GetEventSink(getter_AddRefs(sink));
if (sink) {
sink->OnRedirect(m_pConnection, newURL);
sink->OnRedirect(mConnection, newURL);
}
//
@ -812,8 +812,8 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
// the entity that follows to be discarded without notifying the
// consumer...
//
NS_RELEASE(m_pConsumer);
m_ResponseContext = nsnull;
NS_RELEASE(mConsumer);
mResponseContext = nsnull;
}
}
nsCRT::free(location);

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

@ -85,17 +85,17 @@ protected:
nsresult ProcessRedirection(PRInt32 aStatusCode);
protected:
PRBool m_bHeadersDone;
PRBool m_bFirstLineParsed;
nsHTTPResponse* m_pResponse;
nsHTTPChannel* m_pConnection;
nsIStreamListener* m_pConsumer;
PRUint32 m_ReadLength; // Already read
PRBool mHeadersDone;
PRBool mFirstLineParsed;
nsHTTPResponse* mResponse;
nsHTTPChannel* mConnection;
nsIStreamListener* mConsumer;
PRUint32 mReadLength; // Already read
nsString m_HeaderBuffer;
nsString mHeaderBuffer;
nsCOMPtr<nsISupports> m_ResponseContext;
nsCOMPtr<nsIChannel> m_Channel;
nsCOMPtr<nsISupports> mResponseContext;
nsCOMPtr<nsIChannel> mChannel;
};
#endif /* _nsHTTPResponseListener_h_ */