Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read the current headers without making a new request with JS? [duplicate]

Possible Duplicate:
Accessing HTTP Headers in Javascript?

The only way what i know to read with javascript the current headers is:

var req = new XMLHttpRequest(); req.open('GET', document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); 

But i don't want make a new request, i want read the current headers.

Is this posible? Thanks!

like image 959
fj123x Avatar asked Sep 04 '12 07:09

fj123x


People also ask

Can you have duplicate HTTP headers?

Yes. So, multiple headers with the same name is ok (www-authenticate is such a case) if the entire field-value is defined as a comma-separated list of values.

How do I read request headers?

Reading Request Headers from Servlets Reading headers is very straightforward; just call the getHeader method of the HttpServletRequest , which returns a String if the header was supplied on this request, null otherwise.

Can Javascript read headers?

While you can't ready any headers of HTML response in JS, you can read Server-Timing header, and you can pass arbitrary key-value data through it.

How do I read a header request in node JS?

To see a list of HTTP request headers, you can use : console. log(JSON. stringify(req.


1 Answers

It's not possible to access page headers via Javascript, without sending ajax request.

like image 171
WTK Avatar answered Oct 21 '22 03:10

WTK