Skip to content

Commit

Permalink
Update hyper to 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Eijebong committed Nov 1, 2018
1 parent 95bfaa0 commit 024b40b
Show file tree
Hide file tree
Showing 122 changed files with 3,829 additions and 3,442 deletions.
845 changes: 642 additions & 203 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/constellation/Cargo.toml
Expand Up @@ -22,7 +22,7 @@ euclid = "0.19"
embedder_traits = { path = "../embedder_traits" }
gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
hyper = "0.10"
http = "0.1"
ipc-channel = "0.11"
layout_traits = {path = "../layout_traits"}
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
Expand Down
2 changes: 1 addition & 1 deletion components/constellation/lib.rs
Expand Up @@ -20,7 +20,7 @@ extern crate euclid;
extern crate gaol;
extern crate gfx;
extern crate gfx_traits;
extern crate hyper;
extern crate http;
extern crate ipc_channel;
extern crate keyboard_types;
extern crate layout_traits;
Expand Down
4 changes: 2 additions & 2 deletions components/constellation/network_listener.rs
Expand Up @@ -6,7 +6,7 @@
//! Any redirects that are encountered are followed. Whenever a non-redirect
//! response is received, it is forwarded to the appropriate script thread.

use hyper::header::Location;
use http::header::LOCATION;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use msg::constellation_msg::PipelineId;
Expand Down Expand Up @@ -99,7 +99,7 @@ impl NetworkListener {
};

match metadata.headers {
Some(ref headers) if headers.has::<Location>() => {
Some(ref headers) if headers.contains_key(LOCATION) => {
if self.req_init.url_list.is_empty() {
self.req_init.url_list.push(self.req_init.url.clone());
}
Expand Down
7 changes: 5 additions & 2 deletions components/devtools/Cargo.toml
Expand Up @@ -11,8 +11,11 @@ path = "lib.rs"

[dependencies]
devtools_traits = {path = "../devtools_traits"}
hyper = "0.10"
hyper_serde = "0.8"
headers-core = "0.0.1"
headers-ext = "0.0.3"
http = "0.1"
hyper = "0.12"
hyper_serde = "0.9"
ipc-channel = "0.11"
log = "0.4"
msg = {path = "../msg"}
Expand Down
109 changes: 47 additions & 62 deletions components/devtools/actors/network_event.rs
Expand Up @@ -9,21 +9,20 @@
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use devtools_traits::HttpRequest as DevtoolsHttpRequest;
use devtools_traits::HttpResponse as DevtoolsHttpResponse;
use hyper::header::{ContentType, Cookie};
use hyper::header::Headers;
use hyper::http::RawStatus;
use hyper::method::Method;
use headers_core::HeaderMapExt;
use headers_ext::{ContentType, Cookie};
use http::{header, HeaderMap};
use hyper::{Method, StatusCode};
use protocol::JsonPacketStream;
use serde_json::{Map, Value};
use std::borrow::Cow;
use std::net::TcpStream;
use time;
use time::Tm;

struct HttpRequest {
url: String,
method: Method,
headers: Headers,
headers: HeaderMap,
body: Option<Vec<u8>>,
startedDateTime: Tm,
timeStamp: i64,
Expand All @@ -32,9 +31,9 @@ struct HttpRequest {
}

struct HttpResponse {
headers: Option<Headers>,
status: Option<RawStatus>,
body: Option<Vec<u8>>,
headers: Option<HeaderMap>,
status: Option<(StatusCode, String)>,
body: Option<Vec<u8>>
}

pub struct NetworkEventActor {
Expand Down Expand Up @@ -189,15 +188,11 @@ impl Actor for NetworkEventActor {
let mut headers = Vec::new();
let mut rawHeadersString = "".to_owned();
let mut headersSize = 0;
for item in self.request.headers.iter() {
let name = item.name();
let value = item.value_string();
rawHeadersString = rawHeadersString + name + ":" + &value + "\r\n";
headersSize += name.len() + value.len();
headers.push(Header {
name: name.to_owned(),
value: value.to_owned(),
});
for (name, value) in self.request.headers.iter() {
let value = &value.to_str().unwrap().to_string();
rawHeadersString = rawHeadersString + name.as_str() + ":" + &value + "\r\n";
headersSize += name.as_str().len() + value.len();
headers.push(Header { name: name.as_str().to_owned(), value: value.to_owned() });
}
let msg = GetRequestHeadersReply {
from: self.name(),
Expand All @@ -210,11 +205,10 @@ impl Actor for NetworkEventActor {
},
"getRequestCookies" => {
let mut cookies = Vec::new();
if let Some(req_cookies) = self.request.headers.get_raw("Cookie") {
for cookie in &*req_cookies {
if let Ok(cookie_value) = String::from_utf8(cookie.clone()) {
cookies = cookie_value.into_bytes();
}

for cookie in self.request.headers.get_all(header::COOKIE) {
if let Ok(cookie_value) = String::from_utf8(cookie.as_bytes().to_vec()) {
cookies = cookie_value.into_bytes();
}
}

Expand All @@ -239,17 +233,15 @@ impl Actor for NetworkEventActor {
let mut headers = vec![];
let mut rawHeadersString = "".to_owned();
let mut headersSize = 0;
for item in response_headers.iter() {
let name = item.name();
let value = item.value_string();
for (name, value) in response_headers.iter() {
headers.push(Header {
name: name.to_owned(),
value: value.clone(),
name: name.as_str().to_owned(),
value: value.to_str().unwrap().to_owned(),
});
headersSize += name.len() + value.len();
rawHeadersString.push_str(name);
headersSize += name.as_str().len() + value.len();
rawHeadersString.push_str(name.as_str());
rawHeadersString.push_str(":");
rawHeadersString.push_str(&value);
rawHeadersString.push_str(value.to_str().unwrap());
rawHeadersString.push_str("\r\n");
}
let msg = GetResponseHeadersReply {
Expand All @@ -264,11 +256,10 @@ impl Actor for NetworkEventActor {
},
"getResponseCookies" => {
let mut cookies = Vec::new();
if let Some(res_cookies) = self.request.headers.get_raw("set-cookie") {
for cookie in &*res_cookies {
if let Ok(cookie_value) = String::from_utf8(cookie.clone()) {
cookies = cookie_value.into_bytes();
}
// TODO: This seems quite broken
for cookie in self.request.headers.get_all(header::SET_COOKIE) {
if let Ok(cookie_value) = String::from_utf8(cookie.as_bytes().to_vec()) {
cookies = cookie_value.into_bytes();
}
}

Expand Down Expand Up @@ -330,8 +321,8 @@ impl NetworkEventActor {
name: name,
request: HttpRequest {
url: String::new(),
method: Method::Get,
headers: Headers::new(),
method: Method::GET,
headers: HeaderMap::new(),
body: None,
startedDateTime: time::now(),
timeStamp: time::get_time().sec,
Expand Down Expand Up @@ -363,7 +354,7 @@ impl NetworkEventActor {
self.response.headers = response.headers.clone();
self.response.status = response.status.as_ref().map(|&(s, ref st)| {
let status_text = String::from_utf8_lossy(st).into_owned();
RawStatus(s, Cow::from(status_text))
(StatusCode::from_u16(s).unwrap(), status_text)
});
self.response.body = response.body.clone();
}
Expand All @@ -385,13 +376,8 @@ impl NetworkEventActor {
// TODO: Send the correct values for all these fields.
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len());
let hSize = hSizeOption.unwrap_or(0);
let (status_code, status_message) = self
.response
.status
.as_ref()
.map_or((0, "".to_owned()), |&RawStatus(ref code, ref text)| {
(*code, text.clone().into_owned())
});
let (status_code, status_message) = self.response.status.as_ref()
.map_or((0, "".to_owned()), |(code, text)| (code.as_u16(), text.clone()));
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
ResponseStartMsg {
httpVersion: "HTTP/1.1".to_owned(),
Expand All @@ -407,9 +393,9 @@ impl NetworkEventActor {
pub fn response_content(&self) -> ResponseContentMsg {
let mut mString = "".to_owned();
if let Some(ref headers) = self.response.headers {
mString = match headers.get() {
Some(&ContentType(ref mime)) => mime.to_string(),
None => "".to_owned(),
mString = match headers.typed_get::<ContentType>() {
Some(ct) => ct.to_string(),
_ => "".to_owned()
};
}
// TODO: Set correct values when response's body is sent to the devtools in http_loader.
Expand All @@ -424,9 +410,9 @@ impl NetworkEventActor {
pub fn response_cookies(&self) -> ResponseCookiesMsg {
let mut cookies_size = 0;
if let Some(ref headers) = self.response.headers {
cookies_size = match headers.get() {
Some(&Cookie(ref cookie)) => cookie.len(),
None => 0,
cookies_size = match headers.typed_get::<Cookie>() {
Some(ref cookie) => cookie.len(),
_ => 0,
};
}
ResponseCookiesMsg {
Expand All @@ -439,8 +425,8 @@ impl NetworkEventActor {
let mut headers_byte_count = 0;
if let Some(ref headers) = self.response.headers {
headers_size = headers.len();
for item in headers.iter() {
headers_byte_count += item.name().len() + item.value_string().len();
for (name, value) in headers.iter() {
headers_byte_count += name.as_str().len() + value.len();
}
}
ResponseHeadersMsg {
Expand All @@ -450,21 +436,20 @@ impl NetworkEventActor {
}

pub fn request_headers(&self) -> RequestHeadersMsg {
let size = self
.request
.headers
.iter()
.fold(0, |acc, h| acc + h.name().len() + h.value_string().len());
let size = self.request
.headers
.iter()
.fold(0, |acc, (name, value)| acc + name.as_str().len() + value.len());
RequestHeadersMsg {
headers: self.request.headers.len(),
headersSize: size,
}
}

pub fn request_cookies(&self) -> RequestCookiesMsg {
let cookies_size = match self.request.headers.get() {
Some(&Cookie(ref cookie)) => cookie.len(),
None => 0,
let cookies_size = match self.request.headers.typed_get::<Cookie>() {
Some(ref cookie) => cookie.len(),
_ => 0
};
RequestCookiesMsg {
cookies: cookies_size,
Expand Down
3 changes: 3 additions & 0 deletions components/devtools/lib.rs
Expand Up @@ -13,6 +13,9 @@
#![deny(unsafe_code)]

extern crate devtools_traits;
extern crate headers_core;
extern crate headers_ext;
extern crate http;
extern crate hyper;
extern crate ipc_channel;
#[macro_use]
Expand Down
3 changes: 1 addition & 2 deletions components/devtools_traits/Cargo.toml
Expand Up @@ -11,8 +11,7 @@ path = "lib.rs"

[dependencies]
bitflags = "1.0"
hyper = "0.10"
hyper_serde = "0.8"
http = "0.1"
ipc-channel = "0.11"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
Expand Down
10 changes: 5 additions & 5 deletions components/devtools_traits/lib.rs
Expand Up @@ -13,7 +13,7 @@

#[macro_use]
extern crate bitflags;
extern crate hyper;
extern crate http;
extern crate ipc_channel;
extern crate malloc_size_of;
#[macro_use]
Expand All @@ -24,8 +24,8 @@ extern crate serde;
extern crate servo_url;
extern crate time;

use hyper::header::Headers;
use hyper::method::Method;
use http::HeaderMap;
use http::method::Method;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use servo_url::ServoUrl;
Expand Down Expand Up @@ -301,7 +301,7 @@ pub enum CachedConsoleMessage {
pub struct HttpRequest {
pub url: ServoUrl,
pub method: Method,
pub headers: Headers,
pub headers: HeaderMap,
pub body: Option<Vec<u8>>,
pub pipeline_id: PipelineId,
pub startedDateTime: Tm,
Expand All @@ -313,7 +313,7 @@ pub struct HttpRequest {

#[derive(Debug, PartialEq)]
pub struct HttpResponse {
pub headers: Option<Headers>,
pub headers: Option<HeaderMap>,
pub status: Option<(u16, Vec<u8>)>,
pub body: Option<Vec<u8>>,
pub pipeline_id: PipelineId,
Expand Down
4 changes: 2 additions & 2 deletions components/malloc_size_of/Cargo.toml
Expand Up @@ -29,8 +29,8 @@ app_units = "0.7"
cssparser = "0.24.0"
euclid = "0.19"
hashglobe = { path = "../hashglobe" }
hyper = { version = "0.10", optional = true }
hyper_serde = { version = "0.8", optional = true }
hyper = { version = "0.12", optional = true }
hyper_serde = { version = "0.9", optional = true }
keyboard-types = {version = "0.4.2-servo", features = ["serde"], optional = true}
mozjs = { version = "0.9.3", optional = true }
selectors = { path = "../selectors" }
Expand Down

0 comments on commit 024b40b

Please sign in to comment.