diff options
Diffstat (limited to 'components/net')
-rw-r--r-- | components/net/http_cache.rs | 11 | ||||
-rw-r--r-- | components/net/http_loader.rs | 3 | ||||
-rw-r--r-- | components/net/resource_thread.rs | 17 |
3 files changed, 12 insertions, 19 deletions
diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs index e47b4e81951..592ad7a99aa 100644 --- a/components/net/http_cache.rs +++ b/components/net/http_cache.rs @@ -230,12 +230,15 @@ fn get_response_expiry(response: &Response) -> Duration { let max_heuristic = Duration::hours(24) - age; let heuristic_freshness = if let Some(last_modified) = // If the response has a Last-Modified header field, - // caches are encouraged to use a heuristic expiration value - // that is no more than some fraction of the interval since that time. - response.headers.typed_get::<LastModified>() { + // caches are encouraged to use a heuristic expiration value + // that is no more than some fraction of the interval since that time. + response.headers.typed_get::<LastModified>() + { let current = time::now().to_timespec(); let last_modified: SystemTime = last_modified.into(); - let last_modified = last_modified.duration_since(SystemTime::UNIX_EPOCH).unwrap(); + let last_modified = last_modified + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap(); let last_modified = Timespec::new(last_modified.as_secs() as i64, 0); // A typical setting of this fraction might be 10%. let raw_heuristic_calc = (current - last_modified) / 10; diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 18e4e696f80..7868556adfe 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -44,7 +44,6 @@ use net_traits::{ use servo_arc::Arc; use servo_url::{ImmutableOrigin, ServoUrl}; use std::collections::{HashMap, HashSet}; -use std::error::Error; use std::iter::FromIterator; use std::mem; use std::ops::Deref; @@ -622,7 +621,7 @@ pub fn http_fetch( HeaderValue::to_str(v) .map(|l| { ServoUrl::parse_with_base(response.actual_response().url(), &l) - .map_err(|err| err.description().into()) + .map_err(|err| err.to_string()) }) .ok() }); diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index c948055bc55..f85d623fe4f 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -40,7 +40,6 @@ use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; use std::borrow::{Cow, ToOwned}; use std::collections::HashMap; -use std::error::Error; use std::fs::{self, File}; use std::io::prelude::*; use std::ops::Deref; @@ -361,7 +360,7 @@ where let mut file = match File::open(&path) { Err(why) => { - warn!("couldn't open {}: {}", display, Error::description(&why)); + warn!("couldn't open {}: {}", display, why); return; }, Ok(file) => file, @@ -369,11 +368,7 @@ where let mut string_buffer: String = String::new(); match file.read_to_string(&mut string_buffer) { - Err(why) => panic!( - "couldn't read from {}: {}", - display, - Error::description(&why) - ), + Err(why) => panic!("couldn't read from {}: {}", display, why), Ok(_) => println!("successfully read from {}", display), } @@ -396,16 +391,12 @@ where let display = path.display(); let mut file = match File::create(&path) { - Err(why) => panic!("couldn't create {}: {}", display, Error::description(&why)), + Err(why) => panic!("couldn't create {}: {}", display, why), Ok(file) => file, }; match file.write_all(json_encoded.as_bytes()) { - Err(why) => panic!( - "couldn't write to {}: {}", - display, - Error::description(&why) - ), + Err(why) => panic!("couldn't write to {}: {}", display, why), Ok(_) => println!("successfully wrote to {}", display), } } |