warren-bank / moz-rewrite

"moz-rewrite" is a Firefox add-on that functions as a light-weight (pseudo) rules-engine for easily modifying HTTP headers in either direction
GNU General Public License v2.0
30 stars 7 forks source link

[question] The modification of response header is not visible in develop tools, is it normal behavior ? #3

Open fireattack opened 9 years ago

fireattack commented 9 years ago

As what I said in the title. I use your great addon Rewrite HTTP Headers (JSON) to modify the response headers. It works great, but I wonder why I can't see any of my modification of RESPONSE header in develop tool - network. Is it normal?

I ask so because if I modify request headers, it can be easily spotted in the headers by network tool.

Sorry if it's a silly question, I'm not a developer.

warren-bank commented 9 years ago

That's not a silly question at all. In fact, it's a really interesting one!

Unfortunately, I'm not familiar enough with Firefox's internals to answer it. And, truthfully, my C++ is decades rusty :P

The Networking tab (within the "Web Developer" tools) must observe HTTP traffic.. both outgoing requests, as well as incoming responses. At the heart of your question, we need to know: specifically how does the Network tab's observer interacts with the "Observer API" that is used by add-ons.

Are they notified synchronous or asynchronous? If synchronous, then what is the order in which observers are given access to the HTTP Channel?

But, making a completely naive guess.. I'm thinking that both observers are probably notified asynchronously. If so, and if they're all working against a common data structure.. then we'd be asking for a race condition.

Ignoring (for a moment) the potential for disaster this would have.. if all observers were, in fact, notified at the same time.. and they did all have access to the same Channel.. then an observer who only needs to read a value (ie: Network tab) will always be faster than the observer who needs to apply a set of rules to conditionally apply updates (ie: moz-rewrite); this could possibly explain why the updates aren't seen by the Networking tab.

I'm aware of a developer who works for Mozilla who is extremely hands-on with Firefox's internals; he's an amazing resource for questions like these. I think I'll pose this one to him, and I'll update with his response when I hear back.

I'm really glad you like the add-on. Thanks for your constructive feedback! Sorry for the late-night rambling :)