Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like the server to know what time the client thinks it is (for client timestamp date correction).

Arguably, this could be achieved by setting a timestamp in the POST body, but that doesn't cover cases where we have to retry the request at a later time, for example.

I'd argue that the most semantic thing to do is to read the client's time from the request's Date header, which the browser should set just before transmission.

However, I can't figure out how to get the browser to include this header (have tested Chrome and Firefox).

The spec lists Date as a forbidden header name:

These are forbidden so the user agent remains in full control over them.

This is fine, because I'd quite like the browser to be in charge of setting the header.

However, the spec also states:

Clients SHOULD only send a Date header field in messages that include an entity-body, as in the case of the PUT and POST requests, and even then it is optional.

So the Date header is optional, and only valid on requests with bodies.

So, given that the Date header is optional, and that the browser retains full control of setting the header, is it possible to get a modern browser to send the Date header with a POST request?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
155 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...