Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set "Date" header for http request

I want to set the header for http request. The header name is "Date"

http_request.setRequestHeader("Date", headers.date);

But, when I see the request going out in firebug. I do not see the request header Date.

How do I set that?

like image 839
hrishikeshp19 Avatar asked Apr 18 '13 22:04

hrishikeshp19


People also ask

What is the date header in HTTP?

The Date property represents the value of a Date HTTP header on an HTTP response. The Date header is the date and time the message was sent. Javascript and . NET languages do not use the DateTime object directly.

Is HTTP date header required?

An origin server MUST NOT send a Date header field if it does not have a clock capable of providing a reasonable approximation of the current instance in Coordinated Universal Time. An origin server MAY send a Date header field if the response is in the 1xx (Informational) or 5xx (Server Error) class of status codes.

How do I set HTTP headers?

Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.

What is HTTP date format?

2 digit minute number, e.g. "04" or "59". 2 digit second number, e.g. "04" or "59". Greenwich Mean Time. HTTP dates are always expressed in GMT, never in local time.


1 Answers

From a XMLHttpRequest, there are a set of headers that cannot be set. Take a look at the spec for setRequestHeader(). Date is one of these headers.

Also, if you look at the WebKit source code, you can see this in implementation.

bool XMLHttpRequest::isAllowedHTTPHeader(const String& name)
{
    initializeXMLHttpRequestStaticData();
    return !staticData->m_forbiddenRequestHeaders.contains(name) 
        && !name.startsWith(staticData->m_proxyHeaderPrefix, false)
        && !name.startsWith(staticData->m_secHeaderPrefix, false);
}
like image 125
Kevin Hakanson Avatar answered Sep 21 '22 15:09

Kevin Hakanson