Skip to content

Commit d1eba8b

Browse files
committed
no need to send date header in client
The date header is optional for clients, but also seems to be discouraged. It's so rare so maybe leave it to the user. https://tools.ietf.org/html/rfc7231#section-7.1.1.2 > A user agent MAY send a Date… The older RFC https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18 > 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. A client > without a clock MUST NOT send a Date header field in a request.
1 parent b911766 commit d1eba8b

File tree

3 files changed

+0
-9
lines changed

3 files changed

+0
-9
lines changed

src/client/encode.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use http_types::{Method, Request};
66

77
use std::pin::Pin;
88

9-
use crate::date::fmt_http_date;
10-
119
/// An HTTP encoder.
1210
#[doc(hidden)]
1311
#[derive(Debug)]
@@ -89,11 +87,6 @@ impl Encoder {
8987
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer
9088
}
9189

92-
let date = fmt_http_date(std::time::SystemTime::now());
93-
buf.write_all(b"date: ").await?;
94-
buf.write_all(date.as_bytes()).await?;
95-
buf.write_all(b"\r\n").await?;
96-
9790
for (header, values) in req.iter() {
9891
for value in values.iter() {
9992
let val = format!("{}: {}\r\n", header, value);

tests/fixtures/request-add-date.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
POST / HTTP/1.1
22
host: localhost:8080
33
content-length: 5
4-
date: {DATE}
54
content-type: text/plain; charset=utf-8
65

76
hello

tests/fixtures/request-with-connect.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ CONNECT example.com:443 HTTP/1.1
22
host: example.com
33
proxy-connection: keep-alive
44
content-length: 0
5-
date: {DATE}
65

0 commit comments

Comments
 (0)