diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index c8f7e8f0c62..e1107f93b99 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -1346,48 +1346,48 @@ nsresult nsHTTPChannel::ResponseCompleted(nsIStreamListener *aListener, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = NS_OK; + nsresult rv = NS_OK; - // - // First: - // - // Call the consumer OnStopRequest(...) to end the request... - if (aListener) { - rv = aListener->OnStopRequest(this, mResponseContext, aStatus, aMsg); + // + // First: + // + // Call the consumer OnStopRequest(...) to end the request... + if (aListener) + { + rv = aListener -> OnStopRequest (this, mResponseContext, aStatus, aMsg); - if (NS_FAILED(rv)) { - PR_LOG(gHTTPLog, PR_LOG_ERROR, - ("nsHTTPChannel::OnStopRequest(...) [this=%x]." - "\tOnStopRequest to consumer failed! Status:%x\n", - this, rv)); + if (NS_FAILED (rv)) + { + PR_LOG(gHTTPLog, PR_LOG_ERROR, ("nsHTTPChannel::OnStopRequest(...) [this=%x]." + "\tOnStopRequest to consumer failed! Status:%x\n", + this, rv)); + } } - } - // - // After the consumer has been notified, remove the channel from its - // load group... This will trigger an OnStopRequest from the load group. - // - if (mLoadGroup) { - (void)mLoadGroup->RemoveChannel(this, nsnull, aStatus, nsnull); - } + // + // After the consumer has been notified, remove the channel from its + // load group... This will trigger an OnStopRequest from the load group. + // + + if (mLoadGroup) + mLoadGroup -> RemoveChannel (this, nsnull, aStatus, nsnull); - // - // Finally, notify the OpenObserver that the request has completed. - // - if (mOpenObserver) { - (void) mOpenObserver->OnStopRequest(this, mOpenContext, aStatus, aMsg); - } + // + // Finally, notify the OpenObserver that the request has completed. + // + if (mOpenObserver) + mOpenObserver -> OnStopRequest (this, mOpenContext, aStatus, aMsg); - // Null out pointers that are no longer needed... + // Null out pointers that are no longer needed... -// rjc says: don't null out mResponseContext; -// it needs to be valid for the life of the channel -// mResponseContext = 0; + // rjc says: don't null out mResponseContext; + // it needs to be valid for the life of the channel + // mResponseContext = 0; - mResponseDataListener = 0; - NS_IF_RELEASE(mCachedResponse); + mResponseDataListener = 0; + NS_IF_RELEASE (mCachedResponse); - return rv; + return rv; } nsresult nsHTTPChannel::SetResponse(nsHTTPResponse* i_pResp) @@ -1775,8 +1775,12 @@ nsHTTPChannel::ProcessStatusCode(void) } nsresult -nsHTTPChannel::ProcessNotModifiedResponse(nsIStreamListener *aListener) +nsHTTPChannel::ProcessNotModifiedResponse (nsIStreamListener *aListener) { + // if there is no cached entry - bail right away + if (!mCachedResponse) + return NS_OK; + nsresult rv; NS_ASSERTION(!mCachedContentIsValid, "We should never have cached a 304 response"); diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h index 31981ec969a..b4ed2ba3db2 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -127,6 +127,7 @@ public: nsHTTPRequest* mRequest; nsHTTPResponseListener* mHTTPServerListener; nsCOMPtr mResponseContext; + nsHTTPResponse* mCachedResponse; protected: nsCOMPtr mOriginalURI; @@ -150,7 +151,6 @@ protected: // Cache-related members nsCOMPtr mCacheEntry; - nsHTTPResponse* mCachedResponse; PRBool mCachedContentIsAvailable; PRBool mCachedContentIsValid; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 6861969d42d..7359326cf05 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -485,23 +485,19 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, // Notify the HTTPChannel that the response has completed... NS_ASSERTION(mChannel, "HTTPChannel is null."); - if (mChannel) { + if (mChannel) + { PRUint32 status = 0; - if (mResponse) { + if (mResponse) mResponse->GetStatus(&status); + + if (!mChannel -> mCachedResponse) + { + mChannel -> ResponseCompleted (mResponseDataListener, i_Status, i_pMsg); + mChannel -> mHTTPServerListener = 0; } - if (status != 304) { - mChannel->ResponseCompleted(mResponseDataListener, - i_Status, i_pMsg); - // The HTTPChannel no longer needs a reference to this object. - mChannel->mHTTPServerListener = 0; - } else { - PR_LOG(gHTTPLog, PR_LOG_DEBUG, - ("nsHTTPServerListener::OnStopRequest [this=%x]. " - "Discarding 304 response\n", this)); - } PRBool keepAlive = PR_FALSE; if (mResponse)