Thanks to the tips in this thread, i've been able to catch the
404 error in the gtkmozembed code (embedding/browser/gtk/src/) by a couple
of changes. Now i'm not sure, if this is the best way to do this, but it
worked for me.
I searched for nsIRequest, nsIHttpChannel in the code & found that
in mozilla-1.7.12/modules/plugin/base/src/nsPluginHostImpl.cpp
the function
nsPluginStreamListenerPeer::OnStartRequest
has the following code to catch 404 errors
{....
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
// deal with 404 (Not Found) HTTP response,
// just return, this causes the request to be ignored.
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) {
PRUint32 responseCode = 0;
rv = httpChannel->GetResponseStatus(&responseCode);
I copied this over to EmbedProgress::OnStateChange() &
am able to catch the error code there.
Thanks!!"Boris Zbarsky" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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