servo: Merge #16288 - Kill ResourceGroup (from nox:net); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 8f2ceb41dd1a039f1d0150dcb1c4e2ba6b22afa2
This commit is contained in:
Anthony Ramine
2017-04-07 05:53:31 -05:00
parent 77f104b5cf
commit b7ae6ba202
8 changed files with 55 additions and 83 deletions

View File

@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use brotli::Decompressor;
use connector::Connector;
use connector::{Connector, create_http_connector};
use cookie;
use cookie_storage::CookieStorage;
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest};
@@ -27,6 +27,7 @@ use hyper::header::{Pragma, Quality, QualityItem, Referer, SetCookie};
use hyper::header::{UserAgent, q, qitem};
use hyper::method::Method;
use hyper::status::StatusCode;
use hyper_openssl::OpensslClient;
use hyper_serde::Serde;
use log;
use msg::constellation_msg::PipelineId;
@@ -43,7 +44,7 @@ use std::io::{self, Read, Write};
use std::iter::FromIterator;
use std::mem;
use std::ops::Deref;
use std::sync::{Arc, RwLock};
use std::sync::RwLock;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use time;
@@ -68,14 +69,18 @@ pub struct HttpState {
pub hsts_list: RwLock<HstsList>,
pub cookie_jar: RwLock<CookieStorage>,
pub auth_cache: RwLock<AuthCache>,
pub ssl_client: OpensslClient,
pub connector: Pool<Connector>,
}
impl HttpState {
pub fn new() -> HttpState {
pub fn new(ssl_client: OpensslClient) -> HttpState {
HttpState {
hsts_list: RwLock::new(HstsList::new()),
cookie_jar: RwLock::new(CookieStorage::new(150)),
auth_cache: RwLock::new(AuthCache::new()),
ssl_client: ssl_client.clone(),
connector: create_http_connector(ssl_client),
}
}
}
@@ -389,7 +394,7 @@ fn auth_from_cache(auth_cache: &RwLock<AuthCache>, origin: &ImmutableOrigin) ->
}
}
fn obtain_response(connector: Arc<Pool<Connector>>,
fn obtain_response(connector: &Pool<Connector>,
url: &ServoUrl,
method: &Method,
request_headers: &Headers,
@@ -819,14 +824,11 @@ fn http_network_or_cache_fetch(request: &mut Request,
};
// Step 11
if !http_request.omit_origin_header {
let method = &http_request.method;
if cors_flag || (*method != Method::Get && *method != Method::Head) {
debug_assert!(http_request.origin != Origin::Client);
if let Origin::Origin(ref url_origin) = http_request.origin {
if let Some(hyper_origin) = try_immutable_origin_to_hyper_origin(url_origin) {
http_request.headers.set(hyper_origin)
}
if cors_flag || (http_request.method != Method::Get && http_request.method != Method::Head) {
debug_assert!(http_request.origin != Origin::Client);
if let Origin::Origin(ref url_origin) = http_request.origin {
if let Some(hyper_origin) = try_immutable_origin_to_hyper_origin(url_origin) {
http_request.headers.set(hyper_origin)
}
}
}
@@ -1079,7 +1081,9 @@ fn http_network_fetch(request: &Request,
// do not. Once we support other kinds of fetches we'll need to be more fine grained here
// since things like image fetches are classified differently by devtools
let is_xhr = request.destination == Destination::None;
let wrapped_response = obtain_response(context.connector.clone(), &url, &request.method,
let wrapped_response = obtain_response(&context.state.connector,
&url,
&request.method,
&request.headers,
&request.body, &request.method,
&request.pipeline_id, request.redirect_count + 1,