HighDots Forums  

Read HTTP Headers with Javascript???

Javascript JavaScript language (comp.lang.javascript)


Discuss Read HTTP Headers with Javascript??? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rick Edwards
 
Posts: n/a

Default Read HTTP Headers with Javascript??? - 09-25-2003 , 02:15 PM






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





Reply With Quote
  #2  
Old   
Stephen
 
Posts: n/a

Default Re: Read HTTP Headers with Javascript??? - 09-25-2003 , 02:46 PM






Rick Edwards wrote:

Quote:
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....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



Reply With Quote
  #3  
Old   
Alexander Ignatyev
 
Posts: n/a

Default Re: Read HTTP Headers with Javascript??? - 09-25-2003 , 03:14 PM




"Rick Edwards" <ricke (AT) NOSPAMsasktel (DOT) net> wrote :

Quote:
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.




Reply With Quote
  #4  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Read HTTP Headers with Javascript??? - 09-26-2003 , 04:18 AM





Rick Edwards wrote:

Quote:
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/



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.