Re: Hooks into PR_Write and PR_Read
gregory boyle <[email protected]> Mon, 7 Dec 2009 17:57:26 -0800 (PST)
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
On Dec 6, 9:16 am, "[email protected]" <[email protected]> wrote: > Hello, > > I'm developing an application that will hook into Mozilla Firefox PR_Read and PR_Write, which will be able to tamper requests and responses. Hooking works fine, but I'm having troubles. > > The hook for PR_Write works in a way that will collect all the output for an request, tamper it and do the real send, using another call to original PR_Write. My problem is that I need to write and read all the data before I return it to Firefox. I know that the sockets are in non-blocking mode, so if I get -1 as return code and last error would block, then I just pause a bit and retry sending or reading, so I return to Firefox only when all the request was sent or all the response was read. > > Is this the right approach? Because on some websites, I keep getting -1 and would block forever, and I get stuck in my sending or receiving loop. > > Any help would be greatly appreciated, > Thanks. Hello, It's me again. I've passed this problem but now I got another one. After I receive the entire response, and I start outputing it using my PR_Recv hook, Firefox reads 4096 bytes a few times but after that it stops reading, and after a little while around 20 seconds, it reads again. Why is this behaviour? Even if I don't modify the response at all, it still does the same. Thanks !