hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.07k stars 1.55k forks source link

Customization of whether server date headers are sent #3644

Closed edwardwc closed 1 month ago

edwardwc commented 2 months ago

Initially starting with issue #912 then followed up with pull request #2751, this pull request addresses the need for customizing whether the server sends the date header for http/2 and http/1.1.

According to RFC7231#7.1.1.2, it is not always preferable to send the date header if the system may not have access to time or may not be accurate. Additionally, disabling the date header will result in slight performance gains.

This pull request aims to allow users to customize when building the http1 or http2 service whether the date headers should be sent in responses, with a similar API to other boolean options. It also integrates tests for both http1 and 2 to prevent regression.

If you have suggestions, questions, comments, please comment on this pull request! I will promptly make changes.

Have an incredible rest of your day.

edwardwc commented 2 months ago

@seanmonstar auto_date_header does make more sense!