mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 767087 - Add a flag to force content sniffing when we get served application/octet-stream. r=jduell
This commit is contained in:
parent
664f271620
commit
2f16fd55a4
@ -241,6 +241,14 @@ interface nsIChannel : nsIRequest
|
|||||||
*/
|
*/
|
||||||
const unsigned long LOAD_CLASSIFY_URI = 1 << 22;
|
const unsigned long LOAD_CLASSIFY_URI = 1 << 22;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this flag is set and a server's response is Content-Type
|
||||||
|
* application/octet-steam, the server's Content-Type will be ignored and
|
||||||
|
* the channel content will be sniffed as though no Content-Type had been
|
||||||
|
* passed.
|
||||||
|
*/
|
||||||
|
const unsigned long LOAD_TREAT_APPLICATION_OCTET_STREAM_AS_UNKNOWN = 1 << 23;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to the type implied or stated by the Content-Disposition header
|
* Access to the type implied or stated by the Content-Disposition header
|
||||||
* if available and if applicable. This allows determining inline versus
|
* if available and if applicable. This allows determining inline versus
|
||||||
|
@ -682,9 +682,15 @@ CallUnknownTypeSniffer(void *aClosure, const PRUint8 *aData, PRUint32 aCount)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBaseChannel::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
nsBaseChannel::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||||
{
|
{
|
||||||
// If our content type is unknown, then use the content type sniffer. If the
|
// If our content type is unknown or if the content type is
|
||||||
// sniffer is not available for some reason, then we just keep going as-is.
|
// application/octet-stream and the caller requested it, use the content type
|
||||||
if (NS_SUCCEEDED(mStatus) && mContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
|
// sniffer. If the sniffer is not available for some reason, then we just keep
|
||||||
|
// going as-is.
|
||||||
|
bool shouldSniff = mContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE) ||
|
||||||
|
((mLoadFlags & LOAD_TREAT_APPLICATION_OCTET_STREAM_AS_UNKNOWN) &&
|
||||||
|
mContentType.EqualsLiteral(APPLICATION_OCTET_STREAM));
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(mStatus) && shouldSniff) {
|
||||||
mPump->PeekStream(CallUnknownTypeSniffer, static_cast<nsIChannel*>(this));
|
mPump->PeekStream(CallUnknownTypeSniffer, static_cast<nsIChannel*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,8 +881,11 @@ nsresult
|
|||||||
nsHttpChannel::CallOnStartRequest()
|
nsHttpChannel::CallOnStartRequest()
|
||||||
{
|
{
|
||||||
mTracingEnabled = false;
|
mTracingEnabled = false;
|
||||||
|
bool shouldSniff = mResponseHead && (mResponseHead->ContentType().IsEmpty() ||
|
||||||
|
((mResponseHead->ContentType().EqualsLiteral(APPLICATION_OCTET_STREAM) &&
|
||||||
|
(mLoadFlags & LOAD_TREAT_APPLICATION_OCTET_STREAM_AS_UNKNOWN))));
|
||||||
|
|
||||||
if (mResponseHead && mResponseHead->ContentType().IsEmpty()) {
|
if (shouldSniff) {
|
||||||
NS_ASSERTION(mConnectionInfo, "Should have connection info here");
|
NS_ASSERTION(mConnectionInfo, "Should have connection info here");
|
||||||
if (!mContentTypeHint.IsEmpty())
|
if (!mContentTypeHint.IsEmpty())
|
||||||
mResponseHead->SetContentType(mContentTypeHint);
|
mResponseHead->SetContentType(mContentTypeHint);
|
||||||
|
Loading…
Reference in New Issue
Block a user