bug #16897. Consolidated the firing of OnStopRequest into the nsHTTPChannel. This is also called if a transport fails to be created...

This commit is contained in:
rpotts%netscape.com 1999-10-27 06:48:53 +00:00
Родитель bd9f6bb44d
Коммит 80d39f4a4d
4 изменённых файлов: 26 добавлений и 27 удалений

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

@ -649,8 +649,11 @@ nsHTTPChannel::Open(void)
mState = HS_WAITING_FOR_OPEN;
return NS_OK;
}
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
// Unable to create a transport... End the request...
(void) ResponseCompleted(nsnull, rv, nsnull);
return rv;
}
// Check for any modules that want to set headers before we
// send out a request.
NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv);
@ -799,10 +802,25 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
nsresult nsHTTPChannel::ResponseCompleted(nsIChannel* aTransport,
nsresult aStatus)
nsresult aStatus,
const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
// Call the consumer OnStopRequest(...) to end the request...
if (mResponseDataListener) {
rv = mResponseDataListener->OnStopRequest(this,
mResponseContext,
aStatus,
aMsg);
if (NS_FAILED(rv)) {
PR_LOG(gHTTPLog, PR_LOG_ERROR,
("nsHTTPChannel::ResponseCompleted(...) [this=%x]."
"\tOnStopRequest to consumer failed! Status:%x\n",
this, rv));
}
}
// Null out pointers that are no longer needed...
mResponseContext = null_nsCOMPtr();
NS_IF_RELEASE(mResponseDataListener);

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

@ -70,7 +70,8 @@ public:
nsresult Redirect(const char *aURL,
nsIChannel **aResult);
nsresult ResponseCompleted(nsIChannel* aTransport,
nsresult aStatus);
nsresult aStatus,
const PRUnichar* aMsg);
nsresult SetResponse(nsHTTPResponse* i_pResp);
nsresult GetResponseContext(nsISupports** aContext);
nsresult SetContentLength(PRInt32 aContentLength);

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

@ -449,24 +449,14 @@ nsHTTPRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Context,
//
// An error occurred when trying to write the request to the server!
//
// Call the consumer OnStopRequest(...) to end the request...
//
else {
nsCOMPtr<nsIStreamListener> consumer;
nsCOMPtr<nsISupports> consumerContext;
PR_LOG(gHTTPLog, PR_LOG_ERROR,
("nsHTTPRequest [this=%x]. Error writing request to server."
"\tStatus: %x\n",
this, iStatus));
(void) mConnection->GetResponseContext(getter_AddRefs(consumerContext));
rv = mConnection->GetResponseDataListener(getter_AddRefs(consumer));
if (consumer) {
consumer->OnStopRequest(mConnection, consumerContext, iStatus, i_Msg);
}
// Notify the channel that the request has finished
mConnection->ResponseCompleted(mTransport, iStatus);
// Notify the HTTPChannel that the request has finished
mConnection->ResponseCompleted(mTransport, iStatus, i_Msg);
mTransport = null_nsCOMPtr();
rv = iStatus;

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

@ -229,20 +229,10 @@ nsHTTPResponseListener::OnStopRequest(nsIChannel* channel,
}
}
// Pass the notification out to the consumer...
if (mConsumer) {
rv = mConsumer->OnStopRequest(mConnection, mResponseContext, i_Status, i_pMsg);
if (NS_FAILED(rv)) {
PR_LOG(gHTTPLog, PR_LOG_ERROR,
("\tOnStopRequest [this=%x]. Consumer failed!"
"Status: %x\n", this, rv));
}
}
// Notify the HTTPChannel that the response has completed...
NS_ASSERTION(mConnection, "HTTPChannel is null.");
if (mConnection) {
mConnection->ResponseCompleted(channel, i_Status);
mConnection->ResponseCompleted(channel, i_Status, i_pMsg);
}
// The Consumer is no longer needed...