aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits
diff options
context:
space:
mode:
Diffstat (limited to 'components/net_traits')
-rw-r--r--components/net_traits/Cargo.toml15
-rw-r--r--components/net_traits/lib.rs41
-rw-r--r--components/net_traits/request.rs4
-rw-r--r--components/net_traits/response.rs5
4 files changed, 47 insertions, 18 deletions
diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml
index 52877605b15..117ebe87fc9 100644
--- a/components/net_traits/Cargo.toml
+++ b/components/net_traits/Cargo.toml
@@ -12,17 +12,18 @@ path = "lib.rs"
[dependencies]
util = {path = "../util"}
msg = {path = "../msg"}
-ipc-channel = "0.4.0"
+ipc-channel = "0.5"
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
-hyper = { version = "0.9.9", features = [ "serde-serialization" ] }
+hyper = "0.9.9"
+hyper_serde = "0.1.4"
image = "0.10"
lazy_static = "0.2"
log = "0.3.5"
num-traits = "0.1.32"
-serde = "0.7.15"
-serde_macros = "0.7.15"
-url = {version = "1.0.0", features = ["heap_size"]}
+serde = "0.8"
+serde_macros = "0.8"
+url = {version = "1.2", features = ["heap_size"]}
websocket = "0.17"
-uuid = { version = "0.2.2", features = ["v4", "serde"] }
-cookie = { version = "0.2.5", features = ["serialize-serde", "serialize-rustc" ] }
+uuid = { version = "0.3", features = ["v4", "serde"] }
+cookie = {version = "0.2.5", features = ["serialize-rustc"]}
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index fd2973033eb..a778d3ce76b 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -15,6 +15,7 @@
extern crate cookie as cookie_rs;
extern crate heapsize;
extern crate hyper;
+extern crate hyper_serde;
extern crate image as piston_image;
extern crate ipc_channel;
#[allow(unused_extern_crates)]
@@ -37,6 +38,7 @@ use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::mime::{Attr, Mime};
+use hyper_serde::Serde;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
use request::{Request, RequestInit};
@@ -85,8 +87,12 @@ pub enum LoadContext {
#[derive(Clone, Debug, Deserialize, Serialize, HeapSizeOf)]
pub struct CustomResponse {
#[ignore_heap_size_of = "Defined in hyper"]
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
pub headers: Headers,
#[ignore_heap_size_of = "Defined in hyper"]
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
pub raw_status: RawStatus,
pub body: Vec<u8>
}
@@ -107,11 +113,17 @@ pub struct CustomResponseMediator {
pub struct LoadData {
pub url: Url,
#[ignore_heap_size_of = "Defined in hyper"]
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
pub method: Method,
#[ignore_heap_size_of = "Defined in hyper"]
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
/// Headers that will apply to the initial request only
pub headers: Headers,
#[ignore_heap_size_of = "Defined in hyper"]
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
/// Headers that will apply to the initial request and any redirects
/// Unused in fetch
pub preserved_headers: Headers,
@@ -378,7 +390,12 @@ pub enum WebSocketDomAction {
#[derive(Deserialize, Serialize)]
pub enum WebSocketNetworkEvent {
- ConnectionEstablished(header::Headers, Vec<String>),
+ ConnectionEstablished(
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
+ header::Headers,
+ Vec<String>
+ ),
MessageReceived(MessageData),
Close(Option<u16>, String),
Fail,
@@ -407,11 +424,17 @@ pub enum CoreResourceMsg {
/// Store a set of cookies for a given originating URL
SetCookiesForUrl(Url, String, CookieSource),
/// Store a set of cookies for a given originating URL
- SetCookiesForUrlWithData(Url, Cookie, CookieSource),
+ SetCookiesForUrlWithData(
+ Url,
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
+ Cookie,
+ CookieSource
+ ),
/// Retrieve the stored cookies for a given URL
GetCookiesForUrl(Url, IpcSender<Option<String>>, CookieSource),
/// Get a cookie by name for a given originating URL
- GetCookiesDataForUrl(Url, IpcSender<Vec<Cookie>>, CookieSource),
+ GetCookiesDataForUrl(Url, IpcSender<Vec<Serde<Cookie>>>, CookieSource),
/// Cancel a network request corresponding to a given `ResourceId`
Cancel(ResourceId),
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
@@ -528,18 +551,18 @@ pub struct Metadata {
#[ignore_heap_size_of = "Defined in hyper"]
/// MIME type / subtype.
- pub content_type: Option<(ContentType)>,
+ pub content_type: Option<Serde<ContentType>>,
/// Character set.
pub charset: Option<String>,
#[ignore_heap_size_of = "Defined in hyper"]
/// Headers
- pub headers: Option<Headers>,
+ pub headers: Option<Serde<Headers>>,
#[ignore_heap_size_of = "Defined in hyper"]
/// HTTP Status
- pub status: Option<RawStatus>,
+ pub status: Option<Serde<RawStatus>>,
/// Is successful HTTPS connection
pub https_state: HttpsState,
@@ -557,7 +580,7 @@ impl Metadata {
charset: None,
headers: None,
// https://fetch.spec.whatwg.org/#concept-response-status-message
- status: Some(RawStatus(200, "OK".into())),
+ status: Some(Serde(RawStatus(200, "OK".into()))),
https_state: HttpsState::None,
referrer: None,
}
@@ -566,7 +589,7 @@ impl Metadata {
/// Extract the parts of a Mime that we care about.
pub fn set_content_type(&mut self, content_type: Option<&Mime>) {
match self.headers {
- None => self.headers = Some(Headers::new()),
+ None => self.headers = Some(Serde(Headers::new())),
Some(_) => (),
}
@@ -577,7 +600,7 @@ impl Metadata {
headers.set(ContentType(mime.clone()));
}
- self.content_type = Some(ContentType(mime.clone()));
+ self.content_type = Some(Serde(ContentType(mime.clone())));
let &Mime(_, _, ref parameters) = mime;
for &(ref k, ref v) in parameters {
if &Attr::Charset == k {
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs
index bf7e22d2d0b..a1bf48cbbe9 100644
--- a/components/net_traits/request.rs
+++ b/components/net_traits/request.rs
@@ -111,8 +111,12 @@ pub enum CORSSettings {
#[derive(Serialize, Deserialize, Clone)]
pub struct RequestInit {
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
pub method: Method,
pub url: Url,
+ #[serde(deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize")]
pub headers: Headers,
pub unsafe_request: bool,
pub same_origin_data: bool,
diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs
index ab1d5b1c8f5..37b0a585780 100644
--- a/components/net_traits/response.rs
+++ b/components/net_traits/response.rs
@@ -7,6 +7,7 @@
use hyper::header::{AccessControlExposeHeaders, ContentType, Headers};
use hyper::http::RawStatus;
use hyper::status::StatusCode;
+use hyper_serde::Serde;
use std::ascii::AsciiExt;
use std::cell::{Cell, RefCell};
use std::sync::{Arc, Mutex};
@@ -237,8 +238,8 @@ impl Response {
Some(&ContentType(ref mime)) => Some(mime),
None => None
});
- metadata.headers = Some(self.headers.clone());
- metadata.status = self.raw_status.clone();
+ metadata.headers = Some(Serde(self.headers.clone()));
+ metadata.status = self.raw_status.clone().map(Serde);
metadata.https_state = self.https_state;
return Ok(metadata);
}