зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400655 P1 Respect LOAD_CALL_CONTENT_SNIFFERS when a channel is intercepted by a ServiceWorker. r=valentin
This commit is contained in:
Родитель
24e65c29e3
Коммит
61ffdf4130
|
@ -4339,5 +4339,20 @@ HttpBaseChannel::SetLastRedirectFlags(uint32_t aValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// NOTE: This function duplicates code from nsBaseChannel. This will go away
|
||||
// once HTTP uses nsBaseChannel (part of bug 312760)
|
||||
/* static */ void
|
||||
HttpBaseChannel::CallTypeSniffers(void *aClosure, const uint8_t *aData,
|
||||
uint32_t aCount)
|
||||
{
|
||||
nsIChannel *chan = static_cast<nsIChannel*>(aClosure);
|
||||
|
||||
nsAutoCString newType;
|
||||
NS_SniffContent(NS_CONTENT_SNIFFER_CATEGORY, chan, aData, aCount, newType);
|
||||
if (!newType.IsEmpty()) {
|
||||
chan->SetContentType(newType);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -464,6 +464,9 @@ protected:
|
|||
// Called before we create the redirect target channel.
|
||||
already_AddRefed<nsILoadInfo> CloneLoadInfoForRedirect(nsIURI *newURI, uint32_t redirectFlags);
|
||||
|
||||
static void CallTypeSniffers(void *aClosure, const uint8_t *aData,
|
||||
uint32_t aCount);
|
||||
|
||||
friend class PrivateBrowsingChannel<HttpBaseChannel>;
|
||||
friend class InterceptFailedOnStop;
|
||||
|
||||
|
|
|
@ -681,6 +681,12 @@ HttpChannelChild::DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
|||
Cancel(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSynthesizedResponsePump && mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) {
|
||||
mSynthesizedResponsePump->PeekStream(CallTypeSniffers,
|
||||
static_cast<nsIChannel*>(this));
|
||||
}
|
||||
|
||||
nsresult rv = mListener->OnStartRequest(aRequest, aContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
Cancel(rv);
|
||||
|
|
|
@ -1001,6 +1001,11 @@ InterceptedHttpChannel::OnStartRequest(nsIRequest* aRequest,
|
|||
if (!mProgressSink) {
|
||||
GetCallback(mProgressSink);
|
||||
}
|
||||
|
||||
if (mPump && mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) {
|
||||
mPump->PeekStream(CallTypeSniffers, static_cast<nsIChannel*>(this));
|
||||
}
|
||||
|
||||
if (mListener) {
|
||||
mListener->OnStartRequest(this, mListenerContext);
|
||||
}
|
||||
|
|
|
@ -1320,20 +1320,6 @@ nsHttpChannel::SetupTransaction()
|
|||
return rv;
|
||||
}
|
||||
|
||||
// NOTE: This function duplicates code from nsBaseChannel. This will go away
|
||||
// once HTTP uses nsBaseChannel (part of bug 312760)
|
||||
static void
|
||||
CallTypeSniffers(void *aClosure, const uint8_t *aData, uint32_t aCount)
|
||||
{
|
||||
nsIChannel *chan = static_cast<nsIChannel*>(aClosure);
|
||||
|
||||
nsAutoCString newType;
|
||||
NS_SniffContent(NS_CONTENT_SNIFFER_CATEGORY, chan, aData, aCount, newType);
|
||||
if (!newType.IsEmpty()) {
|
||||
chan->SetContentType(newType);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper Function to report messages to the console when loading
|
||||
// a resource was blocked due to a MIME type mismatch.
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче