Scott Lanning wrote:
  Say that I figure out I need an nsIWebProgress instance
in order to call its AddProgressListener method. Nothing I see
in nsIWebProgress indicates how I can get one of them.

That's because there are several different things which all implement nsIWebProgress in different situations.

For the embedding case, I believe http://www.mozilla.org/projects/embedding/PublicAPIs.html talks about nsIWebProgress and how to get one some.

It seems I might use nsIWebBrowser->AddWebBrowserListener,
where what it says is nsIWeakReference is really my
nsIWebProgressListener.

Yes, this would also work.

  Assuming the above is correct, to retrieve the HTTP status
code (200, 302, 404, etc.), I think I would be concerned
with OnStateChange in nsIWebProgressListener. Its documentation
says "NOTE: aStatus may be a success code even for server generated
errors, such as the HTTP 404 error. In such cases, the request itself
should be queried for extended error information (e.g., for HTTP requests
see nsIHttpChannel)."  I'm apparently to use nsIHttpChannel somehow.

Yes.

How do I get one of those? I don't see anything in nsIRequest.

You call QueryInterface on the request to nsIHttpChannel. If that succeeds, you're good to go. ;) If it fails, that wasn't an HTTP request.

(I'm guessing that GetStatus method of nsIRequest will give me
the same thing as aStatus in OnStateChange?)

It should, yes.

Grepping more, I see that in EmbedProgress.cpp,
it do_QueryInterface an nsIRequest to an nsIChannel.

Right.

And annsIHttpChannel is an nsIChannel. Maybe I could do_QueryInterface
to nsIHttpChannel, instead.

Exactly.

Then finally I call GetResponseStatus on the nsIHttpChannel object.

Yep.

-Boris
_______________________________________________
mozilla-embedding mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-embedding

Reply via email to