On Wed, Jan 25, 2012 at 2:11 AM, Jan Honza Odvarko <[email protected]> wrote: > On Tuesday, January 24, 2012 6:51:41 PM UTC+1, Nathan Mische wrote: >> >> Several Firebug extensions read custom HTTP header info and display >> the contents in Firebug: FirePHP, FireLogger, and my extension, >> ColdFire, just to name a few. The issue we face with the NetMonitor >> API as it is now is that onResponse() may be called before the the >> file.responseHeaders element is created. > > Do you have a test case showing that the file.responseHeaders field is not > set? > Perhaps we could fix this instead of introducing a new event? >
Unfortunately this seems to be timing related so while I can reproduce the issue frequently, I cannot reproduce it consistently. Sometimes headers are available when onResponse is fired, sometimes not. Form what I've gathered most of the time headers are available in netProgress.resondedFile so when NetMonitor.onResponse is fired they have been set up by NetUtils.getHttpHeaders. Other times the headers may not be available until netProgress.stopFile is called, but the only NetMonitor event fired after this point in a request seems to be onResponseBody. However, for whatever reason, onResponseBody is not called for all requests. I can say I'm not the only extension developer dealing with this. Check out the approach used in FireLogger to handle this issue: https://github.com/darwin/firelogger/blob/master/firefox/chrome/content/firelogger.js#L115 >> >> Listening for >> onResponseBody() seems to get around this issue, but that event is not >> fired for all requests, redirects in particular. > > >> >> So I'd like to >> propose a new NetMonitor listener API method, onResponseHeaders(). >> This could be broadcast from the NetUtils.getHttpHeaders() when the >> file.responseHeaders are created. Thoughts? > > Do you already have a specific place in the NetMonitor where such event > should be fired? Yes, as I mentioned I would like to see this even broadcast from NetUtils.getHttpHeaders(). I think you may want to modify NetUtils.getHttpHeaders() to accept an optional context parameter so that the context can be broadcast along with the file when the responseHeaders are set. I could submit a patch if that would be easier to evaluate? > Honza > >> --Nathan > -- You received this message because you are subscribed to the Google Groups "Firebug" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at https://groups.google.com/forum/#!forum/firebug
