From 3bd31af0aa58c36042fe5df8c6f6aaad7303fa2f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 22 Feb 2015 14:24:45 -0700 Subject: [PATCH] servo: Merge #5022 - script_task.rs now utilizes hyper's LastModified header (from KiChjang:hyper-last-modified); r=Manishearth Fixes #4986 Source-Repo: https://github.com/servo/servo Source-Revision: 3d9ff6e880a22de9fc5f9751da5a404e55ea23bf --- servo/components/script/script_task.rs | 41 ++------------------------ 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/servo/components/script/script_task.rs b/servo/components/script/script_task.rs index f29e5690cf54..16785a8abeff 100644 --- a/servo/components/script/script_task.rs +++ b/servo/components/script/script_task.rs @@ -66,8 +66,7 @@ use util::task::spawn_named_with_send_on_failure; use util::task_state; use geom::point::Point2D; -use hyper::header::{Header, Headers, HeaderFormat}; -use hyper::header::parsing as header_parsing; +use hyper::header::{LastModified, Headers}; use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC}; use js::jsapi::{JSContext, JSRuntime, JSObject}; use js::jsapi::{JS_SetGCParameter, JSGC_MAX_BYTES}; @@ -80,14 +79,13 @@ use libc; use std::any::Any; use std::borrow::ToOwned; use std::cell::Cell; -use std::fmt::{self, Display}; use std::mem::replace; use std::num::ToPrimitive; use std::rc::Rc; use std::result::Result; use std::sync::mpsc::{channel, Sender, Receiver, Select}; use std::u32; -use time::{Tm, strptime}; +use time::Tm; thread_local!(pub static STACK_ROOTS: Cell> = Cell::new(None)); @@ -1278,41 +1276,6 @@ pub fn get_page(page: &Rc, pipeline_id: PipelineId) -> Rc { This is a bug.") } -//FIXME(seanmonstar): uplift to Hyper -#[derive(Clone)] -struct LastModified(pub Tm); - -impl Header for LastModified { - #[inline] - fn header_name() -> &'static str { - "Last-Modified" - } - - // Parses an RFC 2616 compliant date/time string, - fn parse_header(raw: &[Vec]) -> Option { - header_parsing::from_one_raw_str(raw).and_then(|s: String| { - let s = s.as_slice(); - strptime(s, "%a, %d %b %Y %T %Z").or_else(|_| { - strptime(s, "%A, %d-%b-%y %T %Z") - }).or_else(|_| { - strptime(s, "%c") - }).ok().map(|tm| LastModified(tm)) - }) - } -} - -impl HeaderFormat for LastModified { - // a localized date/time string in a format suitable - // for document.lastModified. - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - let LastModified(ref tm) = *self; - match tm.tm_utcoff { - 0 => <_ as Display>::fmt(&tm.rfc822(), f), - _ => <_ as Display>::fmt(&tm.to_utc().rfc822(), f) - } - } -} - fn dom_last_modified(tm: &Tm) -> String { format!("{}", tm.to_local().strftime("%m/%d/%Y %H:%M:%S").unwrap()) }