Bug 1169613 - Use content type of synthesized response for JAR channel requests if available. Part 1: Set Content-Type of synthesized reponses for JAR channel requests. r=jdm

This commit is contained in:
Fernando Jimenez 2015-06-05 12:53:58 +02:00
parent bf5a41129c
commit 83a6109df4
4 changed files with 13 additions and 3 deletions

View File

@ -68,6 +68,9 @@ NS_IMETHODIMP
InterceptedJARChannel::SynthesizeHeader(const nsACString& aName,
const nsACString& aValue)
{
if (aName.LowerCaseEqualsLiteral("content-type")) {
mContentType = aValue;
}
return NS_OK;
}
@ -78,7 +81,7 @@ InterceptedJARChannel::FinishSynthesizedResponse()
return NS_ERROR_NOT_AVAILABLE;
}
mChannel->OverrideWithSynthesizedResponse(mSynthesizedInput);
mChannel->OverrideWithSynthesizedResponse(mSynthesizedInput, mContentType);
mResponseBody = nullptr;
mChannel = nullptr;

View File

@ -41,6 +41,9 @@ class InterceptedJARChannel : public nsIInterceptedChannel
// The stream to write the body of the synthesized response.
nsCOMPtr<nsIOutputStream> mResponseBody;
// The content type of the synthesized response.
nsCString mContentType;
// Wether this intercepted channel was performing a navigation.
bool mIsNavigation;

View File

@ -896,7 +896,8 @@ void nsJARChannel::ResetInterception()
}
void
nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput)
nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput,
const nsACString& aContentType)
{
// In our current implementation, the FetchEvent handler will copy the
// response stream completely into the pipe backing the input stream so we
@ -917,6 +918,8 @@ nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput)
return;
}
SetContentType(aContentType);
FinishAsyncOpen();
rv = mSynthesizedResponsePump->AsyncRead(this, nullptr);

View File

@ -91,7 +91,8 @@ private:
void ResetInterception();
// Override this channel's pending response with a synthesized one. The
// content will be asynchronously read from the pump.
void OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput);
void OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput,
const nsACString& aContentType);
nsCString mSpec;