Jacek Prucia wrote:

My application is observing requests and responses using nsIHttpNotify
interface. It needs information both from onModifyRequest and from
onExamineResponse to decide if it makes sense to store certain request
data. My current approach is global variable which is filled with data
at onModifyRequest, and then at onExamineResponse. The problem is that
nsIHttpNotify implementations are called in parallel by subsequent
requests, which blows my application big time.

Assuming that it isn't possible to make mozilla somehow synchronized
on this subject, I have to fix my application. Looks like all I have
to do is to bind extracted information with outgoing request. Then
later, at onExamineResponse I can match response with extracted data
and fill it up if necessary. The binding must be unique, and that
seems quite hard to acomplish. The most easiest way seems to be:

onModifyRequest:
   - generate id
   - nsIHttpChannel.setRequestHeader('MyAppId', id, false);
   - extract data and store it with id

onExamineResposne:
   - nsIHttpChannel.getRequestHeader('MyAppId');
   - lookup data for id

...but this involves actually change in outgoing data. I would like to
avoid that if possible. However, I didn't find anything in
nsIHttpChannel or nsIChannel, that would be unique enough to identify
particular request. I was thinking about nsIChannel.URI.asciiSpec, but
it is possible for the same URL to appear multiple times across single
document (multiple blank.gif images or so), so this won't do.



actually, the image cache makes it so that you hardly ever see this happen.


but, the possibility still exists... especially with things other than images.

maybe you can use the address of the nsIChannel object? in JS i think you can compare the native address of two JS objects by using the '===' operator. though, there could be issues with such an approach. assuming you build a table mapping some key (generated from the nsIChannel) to your associated data, you still have the problem that you don't know when you can remove an element from the table. for example, you might get an onModifyRequest event for a channel, but there is no guarantee that you will see an onExamineResponse. this is because onExamineResponse is only called when a transaction succeeds.

you might have better luck implementing nsIWebProgressListener. (you should get a ton of hits in LXR if you search for nsIWebProgressListener.)

nsIWebProgressListener still doesn't help with the "associating some context with a nsIChannel" though :-/

-Darin

Any hint would be greatly appreciated :)

regards,
--
Jacek Prucia
_______________________________________________
Mozilla-netlib mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-netlib



_______________________________________________ Mozilla-netlib mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-netlib

Reply via email to