By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,221 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,221 IT Pros & Developers. It's quick & easy.

Read HTTP Headers with Javascript???

P: n/a
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


Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rick Edwards wrote:
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


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)
http://groups.google.com/groups?q=va...68.3.44&rnum=1

(using server-side includes)
http://groups.google.com/groups?hl=e...168.3.44#link9
Response: (watch for wrapping long url)
http://groups.google.com/groups?hl=e...ang.javascript
google for "HTTP Headers" in the comp.lang.javascript group

Regards,
Stephen

Jul 20 '05 #2

P: n/a

"Rick Edwards" <ri***@NOSPAMsasktel.net> wrote :
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....


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

HTH.
Jul 20 '05 #3

P: n/a


Rick Edwards wrote:
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....


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.characterSet
in Netscape and
document.charset
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/

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.