Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why send method automatic set Date header? #912

Closed
fengcen opened this issue Sep 9, 2016 · 5 comments
Closed

why send method automatic set Date header? #912

fengcen opened this issue Sep 9, 2016 · 5 comments

Comments

@fengcen
Copy link

fengcen commented Sep 9, 2016

I found the code in write_head():

if !self.headers.has::<header::Date>() {
    self.headers.set(header::Date(header::HttpDate(now_utc())));
}

I don't want to set Date header. What should I do?

@seanmonstar
Copy link
Member

The spec says it's required. See the last sentence of the second paragraph in RFC7231#7.1.1.2:

An origin server MUST send a Date header field[...].

@smithsps
Copy link
Contributor

smithsps commented Sep 9, 2016

RFC7231#7.1.1.2 - 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.

It'd be uncommon, but it's technically possible that hyper could be used on such a system.

@fengcen
Copy link
Author

fengcen commented Sep 10, 2016

Ok. Thank you for the information.

@fengcen fengcen closed this as completed Sep 10, 2016
@seanmonstar
Copy link
Member

@smithsps it could be, so I wouldn't object to some sort of config, I suppose, but I'm left wondering if it realistically ever happens.

@smithsps
Copy link
Contributor

@seanmonstar agreed, the only thing I could think of could be clockless embedded device that for some reason didn't have a NTP sync.

deatondg added a commit to deatondg/hyper that referenced this issue Feb 9, 2022
Add an option to disable the automatic addition of the `DATE` header for
situations when an accurate time is not available or the `DATE` header
is otherwise undesirable, for example communicating with a non-compliant
client.

According to RFC7231#7.1.1.2, '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.' Otherwise, sending the date is required.

Resolves the now closed issue hyperium#912.
deatondg added a commit to deatondg/hyper that referenced this issue Feb 9, 2022
Add an option to disable the automatic addition of the `DATE` header for
situations when an accurate time is not available or the `DATE` header
is otherwise undesirable, for example communicating with a non-compliant
client.

According to RFC7231#7.1.1.2, '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.' Otherwise, sending the date is required.

Resolve the now closed issue hyperium#912.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants