Closed
Bug 388518
Opened 17 years ago
Closed 17 years ago
Can't get nsIHttpChannel when response is image
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
INVALID
People
(Reporter: gboysko, Unassigned)
Details
Attachments
(4 files)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 XPCOMViewer/0.9.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 XPCOMViewer/0.9.5 I am writing a nsIWebProgressListener application which inspects an HTTP Response for specific HTTP Headers. When I encounter an onStateChange with flags STATE_STOP and STATE_IS_REQUEST, I then try to QI the aRequest object for an nsIHttpChannel interface. This works fine when the response is of type "text/html". This fails (QI fails) when the response type is "image/png". Reproducible: Always Steps to Reproduce: 1. 2. 3. Actual Results: aRequest.QueryInterface(Ci.nsIHttpChannel) throws exception Expected Results: aRequest.QueryInterface(Ci.nsIHttpChannel) should succeed regardless of the content type. Either that or I need another way to retrieve an HTTP Response header.
Updated•17 years ago
|
Component: General → Networking: HTTP
Product: Firefox → Core
QA Contact: general → networking.http
Comment 1•17 years ago
|
||
what's aRequest.QueryInterface(Components.interfaces.nsIChannel).URI.spec in the case where QI to nsIHttpChannel fails?
Reporter | ||
Comment 2•17 years ago
|
||
When I am unable to QI for nsIHttpChannel, then the QI for nsIChannel fails as well. Here's a description of the code I used: I have a WebProgessListener that implements onStateChange. When STATE_STOP && STATE_IS_REQUEST, I then call code which does the following: try { // Get the HTTP Channel... var httpChannel = aRequest.QueryInterface(Ci.nsIHttpChannel); // Get the response header... var headerValue = aRequest.getResponseHeader("X-Some-Header"); ... } catch (e) { try { var channel = aRequest.QueryInterface(Ci.nsIChannel); alert("aRequest.QueryInterface(Ci.nsIChannel) is " + channel); alert("aRequest.QueryInterface(Ci.nsIChannel).URI is " + channel.URI); alert("aRequest.QueryInterface(Ci.nsIChannel).URI.spec is " + channel.URI.spec); } catch (e) { alert("Unable to get QI for nsIChannel"); } } The Content-Type is image/png. The Content-Encoding is gzip. The Transfer-Encoding is chunked.
Comment 3•17 years ago
|
||
what's aRequest.name?
Reporter | ||
Comment 4•17 years ago
|
||
Not sure why you are referring to that, but if aRequest is an nsIRequest, then name is the name of the request, often the URI.
Comment 5•17 years ago
|
||
That's not what I meant, I meant - what is the actual value of aRequest.name in the case where the QI to nsIChannel/nsIHttpChannel fails?
Reporter | ||
Comment 6•17 years ago
|
||
Sorry for the confusion. The URL is quite long (~270 chars) and does not refer to a static image, but a dynamically generated one. There is nothing in the URL that would indicate it is an image. Does that explain the problem?
Reporter | ||
Comment 7•17 years ago
|
||
It appears that whether it is a dynamically generated or static image, trying to QI for nsIHttpChannel on an nsIRequest which refers to an image raises an exception. Consider this value for aRequest.name: http://abc-gboysko:8008/WebAbcDash/style/foobar/images/redGradientVert.jpg Calling QI on the aRequest object for this request, as in: var httpChannel = aRequest.QueryInterface(Ci.nsIHttpChannel); throws this exception: [Exception... "Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface]" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "JS frame:: chrome://clientperf/content/monitor.js :: anonymous :: line 408" data: no]
Comment 8•17 years ago
|
||
hm... so the name does start with "http", but QI to nsIHttpChannel fails? that is odd...
Reporter | ||
Comment 9•17 years ago
|
||
This is definitely the case. Would it help to write a test case? If so, should be structured as a Firefox Add-on? Can it be made simpler and still demonstrate the problem?
Comment 10•17 years ago
|
||
yes, a testcase would help. can you make it just a js xpcom component?
Reporter | ||
Comment 11•17 years ago
|
||
I haven't written an XPCOM component, but I'll see what I can do...
Reporter | ||
Comment 12•17 years ago
|
||
Reporter | ||
Comment 13•17 years ago
|
||
Reporter | ||
Comment 14•17 years ago
|
||
Reporter | ||
Comment 15•17 years ago
|
||
Updated•17 years ago
|
Attachment #274497 -
Attachment mime type: application/octet-stream → text/plain
Comment 16•17 years ago
|
||
Hmm. The object in question is the imgIRequest object (which, clearly, is not a channel). I don't think it is a bug that you get that object, but you should also get notifications about the actual channel...
OS: Windows 2000 → All
Hardware: PC → All
Comment 17•17 years ago
|
||
Ah I see. This is working as designed. For images you only get an imgIRequest, not a channel, contrary to my last comment. (There may not always be a channel; the image may come from the image cache, etc.)
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Component: Networking: HTTP → ImageLib
QA Contact: networking.http → imagelib
Resolution: --- → INVALID
Reporter | ||
Comment 18•17 years ago
|
||
So, I guess my question remains: how does one read an HTTP Response Headers set on an image request?
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Comment 19•17 years ago
|
||
you can't, sorry
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago → 17 years ago
Resolution: --- → INVALID
Comment 20•17 years ago
|
||
and please don't morph bugs... if you want a way to get at HTTP headers for images, file a new bug on that.
You need to log in
before you can comment on or make changes to this bug.
Description
•