@@ -5,7 +5,7 @@ use async_std::prelude::*;
5
5
use async_std:: task:: { Context , Poll } ;
6
6
use futures_core:: ready;
7
7
use http_types:: {
8
- headers:: { HeaderName , HeaderValue , CONTENT_LENGTH , TRANSFER_ENCODING } ,
8
+ headers:: { HeaderName , HeaderValue , CONTENT_LENGTH , TRANSFER_ENCODING , DATE } ,
9
9
Body , Request , Response , StatusCode ,
10
10
} ;
11
11
@@ -96,7 +96,7 @@ pub async fn encode(req: Request) -> Result<Encoder, std::io::Error> {
96
96
Ok ( Encoder :: new ( buf, req) )
97
97
}
98
98
99
- /// Decode an HTTP respons on the client.
99
+ /// Decode an HTTP response on the client.
100
100
pub async fn decode < R > ( reader : R ) -> Result < Response , Exception >
101
101
where
102
102
R : Read + Unpin + Send + Sync + ' static ,
@@ -142,6 +142,12 @@ where
142
142
res. insert_header ( name, value) ?;
143
143
}
144
144
145
+ if res. header ( & DATE ) . is_none ( ) {
146
+ let date = format ! ( "Date: {}\r \n " , fmt_http_date( std:: time:: SystemTime :: now( ) ) ) ;
147
+ let value = HeaderValue :: from_str ( std:: str:: from_utf8 ( date. as_bytes ( ) ) ?) ?;
148
+ res. insert_header ( DATE , value) ?;
149
+ }
150
+
145
151
let content_length = res. header ( & CONTENT_LENGTH ) ;
146
152
let transfer_encoding = res. header ( & TRANSFER_ENCODING ) ;
147
153
0 commit comments