Skip to content

Commit

Permalink
Auto merge of #21644 - Eijebong:hyperup, r=<try>
Browse files Browse the repository at this point in the history
WIP: Update hyper to 0.12

Left to do:
 - Fix the influent::Client call
 - servo/webrender#3034
 - hyperium/mime#91
 - sfackler/typed-headers#3 (still need a lot of work)
 - Merge and release the ws stuff (I'll do it once I know everything is ok)
 - Merge and release the influent stuff (Same here, I'll do it once I know everything is ok)
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21644)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Sep 26, 2018
2 parents 515afac + e17a06b commit 9de5abd
Show file tree
Hide file tree
Showing 122 changed files with 3,549 additions and 3,182 deletions.
819 changes: 599 additions & 220 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ opt-level = 3
#
# [patch."https://github.com/servo/<repository>"]
# <crate> = { path = "/path/to/local/checkout" }
hyper_serde = { git = "https://github.com/Eijebong/hyper_serde", branch="bump_mime" }
influent = { git = "https://github.com/Eijebong/influent.rs.git", branch="hyper" }
typed-headers = { git = "https://github.com/Eijebong/typed-headers.git", branch="wip" }
ws = { git = "https://github.com/Eijebong/ws-rs.git", branch="openssl" }
mime = { git = "https://github.com/Eijebong/mime.git", branch="invalid_names_servo"}

[patch."https://github.com/servo/webrender"]
webrender = { git = "https://github.com/Eijebong/webrender", branch="base64" }
webrender_api = { git = "https://github.com/Eijebong/webrender", branch="base64" }
3 changes: 2 additions & 1 deletion components/canvas/webgl_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ impl<T: WebGLExternalImageApi> webrender::ExternalImageHandler for WebGLExternal
/// The WR client should not change the image content until the unlock() call.
fn lock(&mut self,
key: webrender_api::ExternalImageId,
_channel_index: u8) -> webrender::ExternalImage {
_channel_index: u8,
_rendering: webrender_api::ImageRendering) -> webrender::ExternalImage {
let ctx_id = WebGLContextId(key.0 as _);
let (texture_id, size) = self.handler.lock(ctx_id);

Expand Down
2 changes: 1 addition & 1 deletion components/constellation/Cargo.toml
Original file line number Diff line number Diff line change
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"}
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion components/constellation/lib.rs
Original file line number Diff line number Diff line change
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 layout_traits;
#[macro_use]
Expand Down
4 changes: 2 additions & 2 deletions components/constellation/network_listener.rs
Original file line number Diff line number Diff line change
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
4 changes: 3 additions & 1 deletion components/devtools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ path = "lib.rs"

[dependencies]
devtools_traits = {path = "../devtools_traits"}
hyper = "0.10"
http = "0.1"
hyper = "0.12"
hyper_serde = "0.8"
ipc-channel = "0.11"
log = "0.4"
Expand All @@ -20,3 +21,4 @@ serde = "1.0"
serde_json = "1.0"
servo_channel = {path = "../channel"}
time = "0.1"
typed-headers = "0.1"
109 changes: 47 additions & 62 deletions components/devtools/actors/network_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
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 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;
use typed_headers::{ContentType, Cookie, HeaderMapExt};

struct HttpRequest {
url: String,
method: Method,
headers: Headers,
headers: HeaderMap,
body: Option<Vec<u8>>,
startedDateTime: Tm,
timeStamp: i64,
Expand All @@ -32,9 +30,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 +187,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 +204,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 +232,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,14 +255,14 @@ 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();
}
}


let msg = GetResponseCookiesReply {
from: self.name(),
cookies: cookies,
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>() {
Ok(Some(ContentType(ref mime))) => mime.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>() {
Ok(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>() {
Ok(Some(ref cookie)) => cookie.len(),
_ => 0
};
RequestCookiesMsg {
cookies: cookies_size,
Expand Down
2 changes: 2 additions & 0 deletions components/devtools/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![deny(unsafe_code)]

extern crate devtools_traits;
extern crate http;
extern crate hyper;
extern crate ipc_channel;
#[macro_use]
Expand All @@ -23,6 +24,7 @@ extern crate serde;
extern crate serde_json;
extern crate servo_channel;
extern crate time;
extern crate typed_headers;

use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
Expand Down
3 changes: 1 addition & 2 deletions components/devtools_traits/Cargo.toml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions components/layout/display_list/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ impl FragmentDisplayListBuilding for Fragment {
tile_spacing: placement.tile_spacing.to_layout(),
image_rendering: style.get_inherited_box().image_rendering.to_layout(),
alpha_type: webrender_api::AlphaType::PremultipliedAlpha,
color: webrender_api::ColorF::WHITE,
},
);
});
Expand Down Expand Up @@ -1940,6 +1941,7 @@ impl FragmentDisplayListBuilding for Fragment {
.image_rendering
.to_layout(),
alpha_type: webrender_api::AlphaType::PremultipliedAlpha,
color: webrender_api::ColorF::WHITE,
},
);
}
Expand Down Expand Up @@ -1970,6 +1972,7 @@ impl FragmentDisplayListBuilding for Fragment {
tile_spacing: LayoutSize::zero(),
image_rendering: ImageRendering::Auto,
alpha_type: webrender_api::AlphaType::PremultipliedAlpha,
color: webrender_api::ColorF::WHITE,
};

state.add_image_item(base, display_item);
Expand Down
1 change: 1 addition & 0 deletions components/layout/display_list/webrender_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
item.item.image_rendering,
item.item.alpha_type,
item.item.image_key,
webrender_api::ColorF::WHITE,
);
},
DisplayItem::Border(ref item) => {
Expand Down
Loading

0 comments on commit 9de5abd

Please sign in to comment.