Pass correct NPReason code to NPP_URLNotify when error with request (like 404) bug 130152 r=av sr=darin a=dbaron

git-svn-id: svn://10.0.0.236/trunk@116767 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
peterlubczynski%netscape.com
2002-03-18 00:09:48 +00:00
parent 215fcc3f0f
commit a032e8c773
2 changed files with 21 additions and 5 deletions

View File

@@ -631,8 +631,14 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
// check if the stream is of seekable type and later its destruction
// see bug 91140
nsresult rv = NS_OK;
if(mStreamType != nsPluginStreamType_Seek)
rv = CleanUpStream(NPRES_DONE);
if(mStreamType != nsPluginStreamType_Seek) {
NPReason reason = NPRES_DONE;
if (NS_FAILED(status))
reason = NPRES_NETWORK_ERR; // since the stream failed, we need to tell the plugin that
rv = CleanUpStream(reason);
}
if(rv != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;

View File

@@ -1238,8 +1238,11 @@ private:
nsIPluginInstanceOwner *mOwner;
nsIPluginInstance *mInstance;
nsIPluginStreamListener *mPStreamListener;
nsPluginStreamInfo *mPluginStreamInfo;
PRBool mSetUpListener;
nsPluginStreamInfo *mPluginStreamInfo;
PRPackedBool mSetUpListener;
// Set to PR_TRUE if we request failed (like with a HTTP response of 404)
PRPackedBool mRequestFailed;
/*
* Set to PR_TRUE after nsIPluginInstancePeer::OnStartBinding() has
@@ -1684,6 +1687,7 @@ nsPluginStreamListenerPeer::nsPluginStreamListenerPeer()
mStartBinding = PR_FALSE;
mLocalFile = nsnull;
mAbort = PR_FALSE;
mRequestFailed = PR_FALSE;
mPendingRequests = 0;
mHaveFiredOnStartRequest = PR_FALSE;
@@ -1953,9 +1957,11 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo
PRUint32 responseCode = 0;
rv = httpChannel->GetResponseStatus(&responseCode);
if (NS_FAILED(rv) || responseCode > 206) { // not normal
// NPP_Notyfy() will be called from OnStopRequest
// NPP_Notify() will be called from OnStopRequest
// in ns4xPluginStreamListener::CleanUpStream
// return error will cancel this request
// ...and we also need to tell the plugin that
mRequestFailed = PR_TRUE;
return NS_ERROR_FAILURE;
}
@@ -2336,6 +2342,10 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
if (aContentType)
mPluginStreamInfo->SetContentType(aContentType);
// set error status if stream failed so we notify the plugin
if (mRequestFailed)
aStatus = NS_ERROR_FAILURE;
// on error status cleanup the stream
if (mStartBinding || NS_FAILED(aStatus))
{