aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/cookie.rs
diff options
context:
space:
mode:
authorDaniel <ddefisher@gmail.com>2016-04-21 14:00:44 -0400
committerDaniel <ddefisher@gmail.com>2016-04-25 19:39:40 -0400
commitd9c32b273af4f55064016b66ccc8d65ec031448c (patch)
treeed2437c2ac51f94b2e9a9a102ee5a3b59a392941 /components/net/cookie.rs
parentec9e1fe7e6a98b52fc0a8706160ad7f9201440fe (diff)
downloadservo-d9c32b273af4f55064016b66ccc8d65ec031448c.tar.gz
servo-d9c32b273af4f55064016b66ccc8d65ec031448c.zip
read cookie_jar, hsts_list, auth_cache, and local_data from file if profile_dir option is present
Diffstat (limited to 'components/net/cookie.rs')
-rw-r--r--components/net/cookie.rs65
1 files changed, 1 insertions, 64 deletions
diff --git a/components/net/cookie.rs b/components/net/cookie.rs
index 0d82c196cca..e85f0b41397 100644
--- a/components/net/cookie.rs
+++ b/components/net/cookie.rs
@@ -8,7 +8,6 @@
use cookie_rs;
use net_traits::CookieSource;
use pub_domains::PUB_DOMAINS;
-use rustc_serialize::{Encodable, Encoder};
use std::borrow::ToOwned;
use std::net::{Ipv4Addr, Ipv6Addr};
use time::{Tm, now, at, Duration};
@@ -17,7 +16,7 @@ use url::Url;
/// A stored cookie that wraps the definition in cookie-rs. This is used to implement
/// various behaviours defined in the spec that rely on an associated request URL,
/// which cookie-rs and hyper's header parsing do not support.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, RustcDecodable, RustcEncodable)]
pub struct Cookie {
pub cookie: cookie_rs::Cookie,
pub host_only: bool,
@@ -174,65 +173,3 @@ impl Cookie {
true
}
}
-
-impl Encodable for Cookie {
- fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
- s.emit_struct("Cookie", 6, |e| {
- try!(e.emit_struct_field("cookie", 0, |e| RsCookie(self.cookie.clone()).encode(e)));
- try!(e.emit_struct_field("host_only", 1, |e| self.host_only.encode(e)));
- try!(e.emit_struct_field("persistent", 2, |e| self.persistent.encode(e)));
- try!(e.emit_struct_field("creation_time", 3, |e| Time(self.creation_time).encode(e)));
- try!(e.emit_struct_field("last_access", 4, |e| Time(self.last_access).encode(e)));
- match self.expiry_time {
- Some(time) => try!(e.emit_struct_field("expiry_time", 5, |e| Time(time).encode(e))),
- None => {},
- }
- Ok(())
- })
- }
-}
-
-struct Time(Tm);
-
-impl Encodable for Time {
- fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
- let Time(time) = *self;
- s.emit_struct("Time", 11, |e| {
- try!(e.emit_struct_field("tm_sec", 0, |e| time.tm_sec.encode(e)));
- try!(e.emit_struct_field("tm_min", 1, |e| time.tm_min.encode(e)));
- try!(e.emit_struct_field("tm_hour", 2, |e| time.tm_hour.encode(e)));
- try!(e.emit_struct_field("tm_mday", 3, |e| time.tm_mday.encode(e)));
- try!(e.emit_struct_field("tm_mon", 4, |e| time.tm_mon.encode(e)));
- try!(e.emit_struct_field("tm_year", 5, |e| time.tm_year.encode(e)));
- try!(e.emit_struct_field("tm_wday", 6, |e| time.tm_wday.encode(e)));
- try!(e.emit_struct_field("tm_yday", 7, |e| time.tm_yday.encode(e)));
- try!(e.emit_struct_field("tm_isdst", 8, |e| time.tm_isdst.encode(e)));
- try!(e.emit_struct_field("tm_utcoff", 9, |e| time.tm_utcoff.encode(e)));
- try!(e.emit_struct_field("tm_nsec", 10, |e| time.tm_nsec.encode(e)));
- Ok(())
- })
- }
-}
-
-struct RsCookie(cookie_rs::Cookie);
-
-impl Encodable for RsCookie {
- fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
- let RsCookie(ref rs_cookie) = *self;
- s.emit_struct("RsCookie", 9, |e| {
- try!(e.emit_struct_field("name", 0, |e| rs_cookie.name.encode(e)));
- try!(e.emit_struct_field("value", 1, |e| rs_cookie.value.encode(e)));
- match rs_cookie.expires {
- Some(time) => try!(e.emit_struct_field("expires", 2, |e| Time(time).encode(e))),
- None => {},
- }
- try!(e.emit_struct_field("max_age", 3, |e| rs_cookie.max_age.encode(e)));
- try!(e.emit_struct_field("domain", 4, |e| rs_cookie.domain.encode(e)));
- try!(e.emit_struct_field("path", 5, |e| rs_cookie.path.encode(e)));
- try!(e.emit_struct_field("secure", 6, |e| rs_cookie.secure.encode(e)));
- try!(e.emit_struct_field("httponly", 7, |e| rs_cookie.httponly.encode(e)));
- try!(e.emit_struct_field("custom", 8, |e| rs_cookie.custom.encode(e)));
- Ok(())
- })
- }
-}