Getting content from http response ? (http-on-examine-response) - Mozilla

This is a discussion on Getting content from http response ? (http-on-examine-response) - Mozilla ; Hi everyone, I'm writing an extension that inspects the http response content received from one given http server. So far I've tried to use the notification "http-on-examine-response" mechanism which allows me to inspect http headers from the response, but I ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Getting content from http response ? (http-on-examine-response)

  1. Getting content from http response ? (http-on-examine-response)

    Hi everyone,

    I'm writing an extension that inspects the http response content
    received from one given http server. So far I've tried to use the
    notification "http-on-examine-response" mechanism which allows me to
    inspect http headers from the response, but I don't have access to the
    actual content of the response. Indeed, you only have access to the
    nsIHttpChannel interface, which only has methods to get the headers.

    Could anyone point me to the right direction on how to access the http
    content please ?

    Thanks in advance,
    Best regards,


  2. Re: Getting content from http response ? (http-on-examine-response)

    Mfenetre wrote:
    > Could anyone point me to the right direction on how to access the http
    > content please ?


    There are a few options...

    If you're only interested in HTML/XML data, see
    http://lxr.mozilla.org/seamonkey/sou...DataListener.h

    If you want all responses, things get difficult. You could register a
    content sniffer
    (http://lxr.mozilla.org/seamonkey/sou...nsNetCID.h#840)
    and return a new type for all responses. Then, register a stream
    converter for that type. The stream converter can change back the type
    to the original type and inspect the response.

    Hope this helps,
    -christian


  3. Re: Getting content from http response ? (http-on-examine-response)

    Christian Biesinger wrote:
    > If you want all responses, things get difficult. You could register a
    > content sniffer


    Sorry, that doesn't actually help. That would still only get you loads
    as a document (basically the same as the other solution, although you'd
    also get stand-alone images)


  4. nsIUnicharStreamListener

    Mfenetre ha scritto:
    > Hi everyone,
    >
    > I'm writing an extension that inspects the http response content
    > received from one given http server. So far I've tried to use the
    > notification "http-on-examine-response" mechanism which allows me to
    > inspect http headers from the response, but I don't have access to the
    > actual content of the response. Indeed, you only have access to the
    > nsIHttpChannel interface, which only has methods to get the headers.
    >
    > Could anyone point me to the right direction on how to access the http
    > content please ?
    >
    > Thanks in advance,
    > Best regards,
    >

    I'm writing an extension that modify the content (html code) of an http
    response message. I'm writing a component implementing the
    nsIUnicharStreamListener interface. But actually, I only managed to read
    response content. My impression is that with this interface I can only
    read the response content.

  5. Re: nsIUnicharStreamListener

    Daniele Zirpoli wrote:
    > I'm writing an extension that modify the content (html code) of an http
    > response message. I'm writing a component implementing the
    > nsIUnicharStreamListener interface. But actually, I only managed to read
    > response content. My impression is that with this interface I can only
    > read the response content.


    Correct. You could use the stream converter approach that I described in
    another message in this thread if you want to change the data.


  6. Re: nsIUnicharStreamListener

    Christian Biesinger ha scritto:
    > Daniele Zirpoli wrote:
    >> I'm writing an extension that modify the content (html code) of an
    >> http response message. I'm writing a component implementing the
    >> nsIUnicharStreamListener interface. But actually, I only managed to
    >> read response content. My impression is that with this interface I can
    >> only read the response content.

    >
    > Correct. You could use the stream converter approach that I described in
    > another message in this thread if you want to change the data.
    >

    Can you give me some examples or links?

  7. Re: nsIUnicharStreamListener

    Daniele Zirpoli wrote:
    > Can you give me some examples or links?


    The technique is used by Firefox's feed display code:

    http://lxr.mozilla.org/seamonkey/sou...edConverter.js
    http://lxr.mozilla.org/seamonkey/sou...eedSniffer.cpp

    Of course that may be more complex than what you need.


  8. Re: nsIUnicharStreamListener

    Christian Biesinger ha scritto:
    > Daniele Zirpoli wrote:
    >> Can you give me some examples or links?

    >
    > The technique is used by Firefox's feed display code:
    >
    > http://lxr.mozilla.org/seamonkey/sou...edConverter.js
    >
    > http://lxr.mozilla.org/seamonkey/sou...eedSniffer.cpp
    >
    >
    > Of course that may be more complex than what you need.
    >

    ok! thanks a lot!

  9. Re: nsIUnicharStreamListener

    Christian Biesinger ha scritto:
    > Daniele Zirpoli wrote:
    >> Can you give me some examples or links?

    >
    > The technique is used by Firefox's feed display code:
    >
    > http://lxr.mozilla.org/seamonkey/sou...edConverter.js
    >
    > http://lxr.mozilla.org/seamonkey/sou...eedSniffer.cpp
    >
    >
    > Of course that may be more complex than what you need.
    >

    Sorry, but I don't understand how it work. Can you help me?
    Thanks!

+ Reply to Thread