@@ -250,17 +250,7 @@ impl CachePolicy {
250250 res_cc. insert ( "no-cache" . into ( ) , None ) ;
251251 }
252252
253- Self {
254- status,
255- method,
256- res,
257- req,
258- res_cc,
259- req_cc,
260- opts,
261- uri,
262- response_time,
263- }
253+ Self { req, res, uri, status, method, opts, res_cc, req_cc, response_time }
264254 }
265255
266256 /// Returns `true` if the response can be stored in a cache. If it's
@@ -431,7 +421,7 @@ impl CachePolicy {
431421 . iter ( )
432422 . filter ( |( h, _) | !HOP_BY_HOP_HEADERS . contains ( & h. as_str ( ) ) )
433423 {
434- headers. insert ( h. to_owned ( ) , v. to_owned ( ) ) ;
424+ headers. insert ( h. clone ( ) , v. clone ( ) ) ;
435425 }
436426
437427 // 9.1. Connection
@@ -587,7 +577,7 @@ impl CachePolicy {
587577 let last_modified = SystemTime :: UNIX_EPOCH
588578 + Duration :: from_secs ( last_modified. unix_timestamp ( ) . max ( 0 ) as _ ) ;
589579 if let Ok ( diff) = server_date. duration_since ( last_modified) {
590- let secs_left = diff. as_secs ( ) as f64 * self . opts . cache_heuristic as f64 ;
580+ let secs_left = diff. as_secs ( ) as f64 * f64 :: from ( self . opts . cache_heuristic ) ;
591581 return default_min_ttl. max ( Duration :: from_secs ( secs_left as _ ) ) ;
592582 }
593583 }
@@ -738,14 +728,14 @@ impl CachePolicy {
738728 // use other header fields provided in the 304 (Not Modified) response to replace all instances
739729 // of the corresponding header fields in the stored response.
740730 for ( header, old_value) in & self . res {
741- let header = header. to_owned ( ) ;
731+ let header = header. clone ( ) ;
742732 if let Some ( new_value) = response_headers. get ( & header) {
743733 if !EXCLUDED_FROM_REVALIDATION_UPDATE . contains ( & header. as_str ( ) ) {
744- new_response_headers. insert ( header, new_value. to_owned ( ) ) ;
734+ new_response_headers. insert ( header, new_value. clone ( ) ) ;
745735 continue ;
746736 }
747737 }
748- new_response_headers. insert ( header, old_value. to_owned ( ) ) ;
738+ new_response_headers. insert ( header, old_value. clone ( ) ) ;
749739 }
750740 response_status = self . status ;
751741 new_response_headers
0 commit comments