Closed Bug 790524 Opened 12 years ago Closed 12 years ago

The sniffing logic can overwrite sniffed content-type by application/octet-stream

Categories

(Core :: Networking: HTTP, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: padenot, Assigned: padenot)

Details

Attachments

(1 file)

If we successfully sniff a file in [1], but we set a nsUnknownDecoder as mListener in [2], we will end up overwriting what we sniffed when OnDataAvailable for the nsUnknownDecoder is called, because the nsUnknownDecoder does not check if we already have a content-type in the request, but only in its mContentType.

[1]: http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpChannel.cpp
[2]: http://mxr.mozilla.org/mozilla-central/source/netwerk/streamconv/converters/nsUnknownDecoder.cpp#305
And the point is that we should be setting up the unknown decoder, if we do it, _after_ calling content sniffers, I think.

Christian, Jason, does that make sense?
I'm probably missing something here, but 

   http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpChannel.cpp#885

seems to set mContentType when the sniffers are run.  So why isn't nsUnknownDecoder::DetermineContentType failing or returning right away?

  http://mxr.mozilla.org/mozilla-central/source/netwerk/streamconv/converters/nsUnknownDecoder.cpp#307

But that's just from looking at this briefly, without an actual test case to follow.  An xpcshell test or some other steps to repro would be nice.
> So why isn't nsUnknownDecoder::DetermineContentType failing or returning right away?

nsUnknownDecoder is set up as a stream converter in this case, not a content sniffer.  See the beginning of nsHttpChannel::CallOnStartRequest.
hm, that sounds reasonable
This is what comment 1 describes and is green on try.
Attachment #682543 - Flags: review?(bzbarsky)
Comment on attachment 682543 [details] [diff] [review]
Avoid overwriting the content-type by application/octet-stream in the sniffing logic. r=

Perfect, thanks!
Attachment #682543 - Flags: review?(bzbarsky) → review+
Assignee: nobody → paul
https://hg.mozilla.org/mozilla-central/rev/25831c0daacd
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: