Bug 1214305 - Part 6: Use a non-IPC redirect for synthesized upgraded responses to ensure the response URL is correctly propagated; r=mcmanus

This commit is contained in:
Ehsan Akhgari 2015-11-02 11:27:00 -05:00
parent cd0dd2fe66
commit cef4c60f16
3 changed files with 21 additions and 4 deletions

View File

@ -1745,7 +1745,8 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
mInterceptListener = new InterceptStreamListener(this, mListenerContext);
RefPtr<InterceptedChannelContent> intercepted =
new InterceptedChannelContent(this, controller, mInterceptListener);
new InterceptedChannelContent(this, controller,
mInterceptListener, shouldUpgrade);
intercepted->NotifyController();
return NS_OK;
}

View File

@ -332,10 +332,12 @@ InterceptedChannelChrome::GetSecureUpgradedChannelURI(nsIURI** aURI)
InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel,
nsINetworkInterceptController* aController,
InterceptStreamListener* aListener)
InterceptStreamListener* aListener,
bool aSecureUpgrade)
: InterceptedChannelBase(aController)
, mChannel(aChannel)
, mStreamListener(aListener)
, mSecureUpgrade(aSecureUpgrade)
{
}
@ -412,6 +414,10 @@ InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURL
if (!aFinalURLSpec.IsEmpty()) {
nsresult rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec);
NS_ENSURE_SUCCESS(rv, rv);
} else if (mSecureUpgrade) {
nsresult rv = HttpBaseChannel::GetSecureUpgradedURI(originalURI,
getter_AddRefs(responseURI));
NS_ENSURE_SUCCESS(rv, rv);
} else {
responseURI = originalURI;
}
@ -479,7 +485,13 @@ InterceptedChannelContent::GetInternalContentPolicyType(nsContentPolicyType* aPo
NS_IMETHODIMP
InterceptedChannelContent::GetSecureUpgradedChannelURI(nsIURI** aURI)
{
nsCOMPtr<nsIURI> uri = SecureUpgradeChannelURI(mChannel);
nsCOMPtr<nsIURI> uri;
if (mSecureUpgrade) {
uri = SecureUpgradeChannelURI(mChannel);
} else {
nsresult rv = mChannel->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
}
if (uri) {
uri.forget(aURI);
return NS_OK;

View File

@ -102,10 +102,14 @@ class InterceptedChannelContent : public InterceptedChannelBase
// Listener for the synthesized response to fix up the notifications before they reach
// the actual channel.
RefPtr<InterceptStreamListener> mStreamListener;
// Set for intercepted channels that have gone through a secure upgrade.
bool mSecureUpgrade;
public:
InterceptedChannelContent(HttpChannelChild* aChannel,
nsINetworkInterceptController* aController,
InterceptStreamListener* aListener);
InterceptStreamListener* aListener,
bool aSecureUpgrade);
NS_IMETHOD ResetInterception() override;
NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override;