Bug 1169296 - Intercepting top-level document loads is not working with JAR channels. r=jdm

This commit is contained in:
Fernando Jimenez 2015-06-03 10:41:44 +02:00
parent eaea331c4f
commit b999a63de7
2 changed files with 22 additions and 2 deletions

View File

@ -890,7 +890,7 @@ void nsJARChannel::ResetInterception()
{
LOG(("nsJARChannel::ResetInterception [this=%x]\n", this));
// Continue with the origin request.
// Continue with the original request.
nsresult rv = ContinueAsyncOpen();
NS_ENSURE_SUCCESS_VOID(rv);
}
@ -917,6 +917,8 @@ nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput)
return;
}
FinishAsyncOpen();
rv = mSynthesizedResponsePump->AsyncRead(this, nullptr);
NS_ENSURE_SUCCESS_VOID(rv);
}
@ -952,6 +954,14 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
nsRefPtr<InterceptedJARChannel> intercepted =
new InterceptedJARChannel(this, controller, isNavigation);
intercepted->NotifyController();
// We get the JAREntry so we can infer the content type later in case
// that it isn't provided along with the synthesized response.
nsresult rv = mJarURI->GetJAREntry(mJarEntry);
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
@ -1007,11 +1017,18 @@ nsJARChannel::ContinueAsyncOpen()
}
FinishAsyncOpen();
return NS_OK;
}
void
nsJARChannel::FinishAsyncOpen()
{
if (mLoadGroup)
mLoadGroup->AddRequest(this, nullptr);
mOpened = true;
return NS_OK;
}
//-----------------------------------------------------------------------------

View File

@ -82,7 +82,10 @@ private:
// Returns true if this channel should intercept the network request and
// prepare for a possible synthesized response instead.
bool ShouldIntercept();
nsresult ContinueAsyncOpen();
void FinishAsyncOpen();
// Discard the prior interception and continue with the original network
// request.
void ResetInterception();