Reputation: 317
This question is about HTTP Request headers -- not HTTP Response headers.
Is there any way to programmatically make User Agents add or change any HTTP Request Header e.g. by means of HTML, JavaScript, for links or resources from a web page. There exists some HTTP Request Headers that one would think should be able to be controlled programmatically, for example max-stale
.
(One could for example imagine that some optional attribute for HTML-elements <a>
, <link>
, <img>
<script>
etc, could exist that would cause the User Agent to add/change a HTTP request header in its request to the server, but I have not found such an attribute. Similarly, one could think that there should exist some mechanism to control HTTP Request Headers when AJAX is used.)
Turning around the question ...: Why does the HTTP Request Header max-stale
exist at all if it cannot be controlled?
Thanks!
Upvotes: 0
Views: 1221
Reputation: 97717
There are some ways in which you can affect request headers in html, e.g. via a form's enctype attribute. I do not believe there is any way to actually specify the actual header values in html.
For Ajax you can specify request headers, though the browser will block certain headers from being set, I doubt max-stale
is one of them.
Also not only browsers make http request, there are a whole host of applications that do and any of them could easily set the max-stale
header if they wanted.
Upvotes: 1
Reputation: 168
The XMLHTTPResponse setRequestHeader() method can be used to set HTTP request headers for an AJAX request. Various JavaScript libraries expose this function in different ways. For example, with jQuery.ajax() you would set the headers
property of the settings parameter.
Upvotes: 1