Read HTTP Headers with Javascript???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick Edwards

    #1

    Read HTTP Headers with Javascript???

    Can I do this? If I'm passing info in my HTTP headers, can I read this info
    via Javascript? I've seen some hope out there, but nothing definitive - I'm
    hoping to get that answer here....

    TIA
    Rick




  • Stephen

    #2
    Re: Read HTTP Headers with Javascript???

    Rick Edwards wrote:
    [color=blue]
    > Can I do this? If I'm passing info in my HTTP headers, can I read this info
    > via Javascript? I've seen some hope out there, but nothing definitive - I'm
    > hoping to get that answer here....
    >
    > TIA
    > Rick
    >[/color]

    It's one of those ... weeeellll, sort-of... kinds of things.
    Which headers? Those sent with a request or those received with a response?

    Javascript, per se, cannot do this. But (here's the "sort-of") see

    Request: (watch for wrapping long url)
    (using php; similar could be done with asp)


    (using server-side includes)



    Response: (watch for wrapping long url)



    google for "HTTP Headers" in the comp.lang.javas cript group

    Regards,
    Stephen

    Comment

    • Alexander Ignatyev

      #3
      Re: Read HTTP Headers with Javascript???


      "Rick Edwards" <ricke@NOSPAMsa sktel.net> wrote :
      [color=blue]
      > Can I do this? If I'm passing info in my HTTP headers, can I read this[/color]
      info[color=blue]
      > via Javascript? I've seen some hope out there, but nothing definitive -[/color]
      I'm[color=blue]
      > hoping to get that answer here....[/color]

      For IE (5+,don't remember exactly) you can use
      XMLHttpRequest object ->getAllResponse Headers method

      HTH.


      Comment

      • Martin Honnen

        #4
        Re: Read HTTP Headers with Javascript???



        Rick Edwards wrote:
        [color=blue]
        > Can I do this? If I'm passing info in my HTTP headers, can I read this info
        > via Javascript? I've seen some hope out there, but nothing definitive - I'm
        > hoping to get that answer here....[/color]

        Cookies are sent as HTTP headers and JavaScript provides access to
        cookies per
        document.cookie
        Some selected HTTP header information is also made accessible by
        JavaScript for instance
        document.charac terSet
        in Netscape and
        document.charse t
        in IE.
        In general however if your server sends a HTTP response to the browser
        that is rendered inside of a window then JavaScript doesn't provide
        access to HTTP response headers.
        The only way you get access to such headers is if you use XMLHttpRequest
        to send and receive a HTTP request

        --

        Martin Honnen
        http://JavaScript.FAQTs.com/

        Comment

        Working...