зеркало из https://github.com/mozilla/pjs.git
242393 r=darin sr=bz only write content to the pipe if the content started; this
ensures that OnDataAvailable is only called if we have a response head. also, add some assertions.
This commit is contained in:
Родитель
50fa804aae
Коммит
296bc854c5
|
@ -3566,6 +3566,8 @@ nsHttpChannel::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||
// which case we just need to call OnStartRequest/OnStopRequest.
|
||||
if (mResponseHead)
|
||||
return ProcessResponse();
|
||||
|
||||
NS_WARNING("No response head in OnStartRequest");
|
||||
}
|
||||
|
||||
// avoid crashing if mListener happens to be null...
|
||||
|
@ -3706,6 +3708,8 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
|
|||
if (mCanceled)
|
||||
return mStatus;
|
||||
|
||||
NS_ASSERTION(mResponseHead, "No response head in ODA!!");
|
||||
|
||||
NS_ASSERTION(!(mCachedContentIsPartial && (request == mTransactionPump)),
|
||||
"transaction pump not suspended");
|
||||
|
||||
|
|
|
@ -281,15 +281,11 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
|
|||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
NS_ENSURE_ARG_POINTER(trans);
|
||||
NS_ASSERTION(responseHead, "No response head?");
|
||||
|
||||
// we won't change our keep-alive policy unless the server has explicitly
|
||||
// told us to do so.
|
||||
|
||||
if (!trans || !responseHead) {
|
||||
LOG(("nothing to do\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// inspect the connection headers for keep-alive info provided the
|
||||
// transaction completed successfully.
|
||||
const char *val = responseHead->PeekHeader(nsHttp::Connection);
|
||||
|
@ -334,7 +330,7 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
|
|||
else
|
||||
mIdleTimeout = gHttpHandler->IdleTimeout();
|
||||
|
||||
LOG(("Connection can be reused [this=%x idle-timeout=%u\n", this, mIdleTimeout));
|
||||
LOG(("Connection can be reused [this=%x idle-timeout=%u]\n", this, mIdleTimeout));
|
||||
}
|
||||
|
||||
// if we're doing an SSL proxy connect, then we need to check whether or not
|
||||
|
@ -346,9 +342,11 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
|
|||
if (responseHead->Status() == 200) {
|
||||
LOG(("SSL proxy CONNECT succeeded!\n"));
|
||||
*reset = PR_TRUE;
|
||||
ProxyStartSSL();
|
||||
nsresult rv = ProxyStartSSL();
|
||||
if (NS_FAILED(rv)) // XXX need to handle this for real
|
||||
LOG(("ProxyStartSSL failed [rv=%x]\n", rv));
|
||||
mCompletedSSLConnect = PR_TRUE;
|
||||
nsresult rv = mSocketOut->AsyncWait(this, 0, 0, nsnull);
|
||||
rv = mSocketOut->AsyncWait(this, 0, 0, nsnull);
|
||||
// XXX what if this fails -- need to handle this error
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "mSocketOut->AsyncWait failed");
|
||||
}
|
||||
|
@ -694,7 +692,7 @@ nsHttpConnection::SetupSSLProxyConnect()
|
|||
request.SetHeader(nsHttp::Proxy_Authorization, nsDependentCString(val));
|
||||
}
|
||||
|
||||
buf.Truncate(0);
|
||||
buf.Truncate();
|
||||
request.Flatten(buf, PR_FALSE);
|
||||
buf.Append("\r\n");
|
||||
|
||||
|
|
|
@ -257,8 +257,10 @@ nsHttpTransaction::Init(PRUint8 caps,
|
|||
nsHttpResponseHead *
|
||||
nsHttpTransaction::TakeResponseHead()
|
||||
{
|
||||
if (!mHaveAllHeaders)
|
||||
if (!mHaveAllHeaders) {
|
||||
NS_WARNING("response headers not available or incomplete");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsHttpResponseHead *head = mResponseHead;
|
||||
mResponseHead = nsnull;
|
||||
|
@ -791,6 +793,9 @@ nsHttpTransaction::HandleContent(char *buf,
|
|||
if (!mDidContentStart) {
|
||||
rv = HandleContentStart();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// Do not write content to the pipe if we haven't started streaming yet
|
||||
if (!mDidContentStart)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mChunkedDecoder) {
|
||||
|
@ -820,6 +825,7 @@ nsHttpTransaction::HandleContent(char *buf,
|
|||
}
|
||||
else {
|
||||
// when we are just waiting for the server to close the connection...
|
||||
// (no explicit content-length given)
|
||||
*contentRead = count;
|
||||
}
|
||||
|
||||
|
@ -832,7 +838,7 @@ nsHttpTransaction::HandleContent(char *buf,
|
|||
*/
|
||||
}
|
||||
|
||||
LOG(("nsHttpTransaction [this=%x count=%u read=%u mContentRead=%lld mContentLength=%lld]\n",
|
||||
LOG(("nsHttpTransaction::HandleContent [this=%x count=%u read=%u mContentRead=%lld mContentLength=%lld]\n",
|
||||
this, count, *contentRead, mContentRead.mValue, mContentLength.mValue));
|
||||
|
||||
// check for end-of-file
|
||||
|
|
Загрузка…
Ссылка в новой задаче