mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
1. Add an Option<Pipeline_id> field to the LoadData struct, and a corresponding parameter to LoadData::new()
2. Change addEvent in the NetworkEventActor to add_request and add_response
This commit is contained in:
parent
6e91ebb1fe
commit
01eb31ae8a
18 changed files with 152 additions and 151 deletions
|
@ -16,10 +16,8 @@ path = "../msg"
|
||||||
[dependencies.util]
|
[dependencies.util]
|
||||||
path = "../util"
|
path = "../util"
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
url = "0.2.16"
|
|
||||||
hyper = "0.3"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time = "*"
|
time = "*"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
|
url = "*"
|
||||||
|
hyper = "*"
|
||||||
|
|
|
@ -3,28 +3,14 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js).
|
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js).
|
||||||
/// Mediates interaction between the remote web console and equivalent functionality (object
|
/// Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo.
|
||||||
/// inspection, JS evaluation, autocompletion) in Servo.
|
|
||||||
|
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
extern crate url;
|
|
||||||
|
|
||||||
use actor::{Actor, ActorRegistry};
|
use actor::{Actor, ActorRegistry};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
|
use rustc_serialize::json;
|
||||||
use devtools_traits::DevtoolScriptControlMsg;
|
|
||||||
use msg::constellation_msg::PipelineId;
|
|
||||||
use devtools_traits::{DevtoolsControlMsg, NetworkEvent};
|
|
||||||
|
|
||||||
use collections::BTreeMap;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
use std::fmt;
|
|
||||||
use rustc_serialize::json::{self, Json, ToJson};
|
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::num::Float;
|
|
||||||
use std::sync::mpsc::{channel, Sender};
|
|
||||||
use std::borrow::IntoCow;
|
|
||||||
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use hyper::header::Headers;
|
use hyper::header::Headers;
|
||||||
use hyper::http::RawStatus;
|
use hyper::http::RawStatus;
|
||||||
|
@ -43,12 +29,10 @@ struct HttpResponse {
|
||||||
body: Option<Vec<u8>>
|
body: Option<Vec<u8>>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
pub struct NetworkEventActor {
|
||||||
struct GetRequestHeadersReply {
|
pub name: String,
|
||||||
from: String,
|
request: HttpRequest,
|
||||||
headers: String,
|
response: HttpResponse,
|
||||||
headerSize: u8,
|
|
||||||
rawHeaders: String
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(RustcEncodable)]
|
||||||
|
@ -57,25 +41,27 @@ pub struct EventActor {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub method: String,
|
pub method: String,
|
||||||
pub startedDateTime: String,
|
pub startedDateTime: String,
|
||||||
pub isXHR: String,
|
pub isXHR: bool,
|
||||||
pub private: String
|
pub private: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(RustcEncodable)]
|
||||||
pub struct ResponseStartMsg {
|
pub struct ResponseStartMsg {
|
||||||
pub httpVersion: String,
|
pub httpVersion: String,
|
||||||
pub remoteAddress: String,
|
pub remoteAddress: String,
|
||||||
pub remotePort: u8,
|
pub remotePort: u32,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub statusText: String,
|
pub statusText: String,
|
||||||
pub headersSize: u8,
|
pub headersSize: u32,
|
||||||
pub discardResponseBody: bool,
|
pub discardResponseBody: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NetworkEventActor {
|
#[derive(RustcEncodable)]
|
||||||
pub name: String,
|
struct GetRequestHeadersReply {
|
||||||
request: HttpRequest,
|
from: String,
|
||||||
response: HttpResponse,
|
headers: Vec<String>,
|
||||||
|
headerSize: u8,
|
||||||
|
rawHeaders: String
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Actor for NetworkEventActor {
|
impl Actor for NetworkEventActor {
|
||||||
|
@ -86,47 +72,35 @@ impl Actor for NetworkEventActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
_msg: &json::Object,
|
||||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
|
|
||||||
"getRequestHeaders" => {
|
"getRequestHeaders" => {
|
||||||
println!("getRequestHeaders");
|
// TODO: Pass the correct values for headers, headerSize, rawHeaders
|
||||||
let msg = GetRequestHeadersReply {
|
let msg = GetRequestHeadersReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
headers: "headers".to_string(),
|
headers: Vec::new(),
|
||||||
headerSize: 10,
|
headerSize: 10,
|
||||||
rawHeaders: "Raw headers".to_string(),
|
rawHeaders: "Raw headers".to_string(),
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
"getRequestCookies" => {
|
"getRequestCookies" => {
|
||||||
println!("getRequestCookies");
|
false
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getRequestPostData" => {
|
"getRequestPostData" => {
|
||||||
println!("getRequestPostData");
|
false
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getResponseHeaders" => {
|
"getResponseHeaders" => {
|
||||||
println!("getResponseHeaders");
|
false
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getResponseCookies" => {
|
"getResponseCookies" => {
|
||||||
println!("getResponseCookies");
|
false
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getResponseContent" => {
|
"getResponseContent" => {
|
||||||
println!("getResponseContent");
|
false
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => false
|
_ => false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -150,34 +124,34 @@ impl NetworkEventActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addEvent(&mut self, network_event: NetworkEvent) {
|
pub fn add_request(&mut self, url: Url, method: Method, headers: Headers, body: Option<Vec<u8>>) {
|
||||||
match network_event {
|
|
||||||
NetworkEvent::HttpRequest(url, method, headers, body) => {
|
|
||||||
self.request.url = url.serialize();
|
self.request.url = url.serialize();
|
||||||
self.request.method = method.clone();
|
self.request.method = method.clone();
|
||||||
self.request.headers = headers.clone();
|
self.request.headers = headers.clone();
|
||||||
self.request.body = body;
|
self.request.body = body;
|
||||||
}
|
}
|
||||||
NetworkEvent::HttpResponse(headers, status, body) => {
|
|
||||||
|
pub fn add_response(&mut self, headers: Option<Headers>, status: Option<RawStatus>, body: Option<Vec<u8>>) {
|
||||||
self.response.headers = headers.clone();
|
self.response.headers = headers.clone();
|
||||||
self.response.status = status.clone();
|
self.response.status = status.clone();
|
||||||
self.response.body = body.clone();
|
self.response.body = body.clone();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_event_actor(&self) -> EventActor {
|
pub fn get_event_actor(&self) -> EventActor {
|
||||||
|
// TODO: Send the correct values for startedDateTime, isXHR, private
|
||||||
EventActor {
|
EventActor {
|
||||||
actor: self.name(),
|
actor: self.name(),
|
||||||
url: self.request.url.clone(),
|
url: self.request.url.clone(),
|
||||||
method: format!("{}", self.request.method),
|
method: format!("{}", self.request.method),
|
||||||
startedDateTime: "2015-04-22T20:47:08.545Z".to_string(),
|
startedDateTime: "2015-04-22T20:47:08.545Z".to_string(),
|
||||||
isXHR: "false".to_string(),
|
isXHR: false,
|
||||||
private: "false".to_string(),
|
private: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_response_start(&self) -> ResponseStartMsg {
|
pub fn get_response_start(&self) -> ResponseStartMsg {
|
||||||
|
// TODO: Send the correct values for all these fields.
|
||||||
|
// This is a fake message.
|
||||||
ResponseStartMsg {
|
ResponseStartMsg {
|
||||||
httpVersion: "HTTP/1.1".to_string(),
|
httpVersion: "HTTP/1.1".to_string(),
|
||||||
remoteAddress: "63.245.217.43".to_string(),
|
remoteAddress: "63.245.217.43".to_string(),
|
||||||
|
|
|
@ -25,8 +25,8 @@ extern crate rustc_serialize;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate util;
|
extern crate util;
|
||||||
extern crate url;
|
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
|
extern crate url;
|
||||||
|
|
||||||
use actor::{Actor, ActorRegistry};
|
use actor::{Actor, ActorRegistry};
|
||||||
use actors::console::ConsoleActor;
|
use actors::console::ConsoleActor;
|
||||||
|
@ -53,12 +53,6 @@ use std::net::{TcpListener, TcpStream, Shutdown};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use time::precise_time_ns;
|
use time::precise_time_ns;
|
||||||
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use hyper::header::Headers;
|
|
||||||
use hyper::http::RawStatus;
|
|
||||||
use hyper::method::Method;
|
|
||||||
|
|
||||||
mod actor;
|
mod actor;
|
||||||
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
|
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
|
||||||
mod actors {
|
mod actors {
|
||||||
|
@ -279,61 +273,39 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
return console_actor_name;
|
return console_actor_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_first_console_actor(actors: Arc<Mutex<ActorRegistry>>) -> String {
|
|
||||||
let actors = actors.lock().unwrap();
|
|
||||||
let root = actors.find::<RootActor>("root");
|
|
||||||
let ref tab_actor_name = root.tabs[0];
|
|
||||||
let tab_actor = actors.find::<TabActor>(tab_actor_name);
|
|
||||||
let console_actor_name = tab_actor.console.clone();
|
|
||||||
return console_actor_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_network_event_actor(actors: Arc<Mutex<ActorRegistry>>,
|
|
||||||
actor_requests: &mut HashMap<String, String>,
|
|
||||||
request_id: String) -> String {
|
|
||||||
let mut actors = actors.lock().unwrap();
|
|
||||||
match (*actor_requests).entry(request_id) {
|
|
||||||
Occupied(name) => {
|
|
||||||
name.into_mut().clone()
|
|
||||||
}
|
|
||||||
Vacant(entry) => {
|
|
||||||
println!("not found");
|
|
||||||
let actor_name = actors.new_name("netevent");
|
|
||||||
let actor = NetworkEventActor::new(actor_name.clone());
|
|
||||||
entry.insert(actor_name.clone());
|
|
||||||
actors.register(box actor);
|
|
||||||
actor_name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_network_event(actors: Arc<Mutex<ActorRegistry>>,
|
fn handle_network_event(actors: Arc<Mutex<ActorRegistry>>,
|
||||||
mut accepted_connections: Vec<TcpStream>,
|
mut connections: Vec<TcpStream>,
|
||||||
|
actor_pipelines: &HashMap<PipelineId, String>,
|
||||||
actor_requests: &mut HashMap<String, String>,
|
actor_requests: &mut HashMap<String, String>,
|
||||||
|
pipeline_id: PipelineId,
|
||||||
request_id: String,
|
request_id: String,
|
||||||
network_event: NetworkEvent) {
|
network_event: NetworkEvent) {
|
||||||
|
|
||||||
let console_actor_name = find_first_console_actor(actors.clone());
|
let console_actor_name = find_console_actor(actors.clone(), pipeline_id, actor_pipelines);
|
||||||
let netevent_actor_name = find_network_event_actor(actors.clone(), actor_requests, request_id.clone());
|
let netevent_actor_name = find_network_event_actor(actors.clone(), actor_requests, request_id.clone());
|
||||||
let mut actors = actors.lock().unwrap();
|
let mut actors = actors.lock().unwrap();
|
||||||
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
|
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
|
||||||
|
|
||||||
match network_event {
|
match network_event {
|
||||||
NetworkEvent::HttpRequest(..) => {
|
NetworkEvent::HttpRequest(url, method, headers, body) => {
|
||||||
actor.addEvent(network_event);
|
//Store the request information in the actor
|
||||||
|
actor.add_request(url, method, headers, body);
|
||||||
|
|
||||||
|
//Send a networkEvent message to the client
|
||||||
let msg = NetworkEventMsg {
|
let msg = NetworkEventMsg {
|
||||||
from: console_actor_name,
|
from: console_actor_name,
|
||||||
__type__: "networkEvent".to_string(),
|
__type__: "networkEvent".to_string(),
|
||||||
eventActor: actor.get_event_actor(),
|
eventActor: actor.get_event_actor(),
|
||||||
};
|
};
|
||||||
for stream in accepted_connections.iter_mut() {
|
for stream in connections.iter_mut() {
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NetworkEvent::HttpResponse(headers, status, body) => {
|
||||||
|
//Store the response information in the actor
|
||||||
|
actor.add_response(headers, status, body);
|
||||||
|
|
||||||
NetworkEvent::HttpResponse(..) => {
|
//Send a networkEventUpdate (responseStart) to the client
|
||||||
println!("Network event response");
|
|
||||||
actor.addEvent(network_event);
|
|
||||||
let msg = NetworkEventUpdateMsg {
|
let msg = NetworkEventUpdateMsg {
|
||||||
from: netevent_actor_name,
|
from: netevent_actor_name,
|
||||||
__type__: "networkEventUpdate".to_string(),
|
__type__: "networkEventUpdate".to_string(),
|
||||||
|
@ -341,10 +313,33 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
response: actor.get_response_start()
|
response: actor.get_response_start()
|
||||||
};
|
};
|
||||||
|
|
||||||
for stream in accepted_connections.iter_mut() {
|
for stream in connections.iter_mut() {
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: Send the other types of update messages at appropriate times
|
||||||
|
// requestHeaders, requestCookies, responseHeaders, securityInfo, etc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the name of NetworkEventActor corresponding to request_id
|
||||||
|
// Create a new one if it does not exist, add it to the actor_requests hashmap
|
||||||
|
fn find_network_event_actor(actors: Arc<Mutex<ActorRegistry>>,
|
||||||
|
actor_requests: &mut HashMap<String, String>,
|
||||||
|
request_id: String) -> String {
|
||||||
|
let mut actors = actors.lock().unwrap();
|
||||||
|
match (*actor_requests).entry(request_id) {
|
||||||
|
Occupied(name) => {
|
||||||
|
//TODO: Delete from map like Firefox does?
|
||||||
|
name.into_mut().clone()
|
||||||
|
}
|
||||||
|
Vacant(entry) => {
|
||||||
|
let actor_name = actors.new_name("netevent");
|
||||||
|
let actor = NetworkEventActor::new(actor_name.clone());
|
||||||
|
entry.insert(actor_name.clone());
|
||||||
|
actors.register(box actor);
|
||||||
|
actor_name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,18 +367,19 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
Ok(DevtoolsControlMsg::SendConsoleMessage(id, console_message)) =>
|
Ok(DevtoolsControlMsg::SendConsoleMessage(id, console_message)) =>
|
||||||
handle_console_message(actors.clone(), id, console_message,
|
handle_console_message(actors.clone(), id, console_message,
|
||||||
&actor_pipelines),
|
&actor_pipelines),
|
||||||
|
|
||||||
Ok(DevtoolsControlMsg::NetworkEventMessage(request_id, network_event)) => {
|
Ok(DevtoolsControlMsg::NetworkEventMessage(request_id, network_event)) => {
|
||||||
// copy the accepted_connections vector
|
// copy the accepted_connections vector
|
||||||
let mut connections = Vec::<TcpStream>::new();
|
let mut connections = Vec::<TcpStream>::new();
|
||||||
for stream in accepted_connections.iter() {
|
for stream in accepted_connections.iter() {
|
||||||
connections.push(stream.try_clone().unwrap());
|
connections.push(stream.try_clone().unwrap());
|
||||||
}
|
}
|
||||||
handle_network_event(actors.clone(), connections, &mut actor_requests, request_id, network_event);
|
//TODO: Get pipeline_id from NetworkEventMessage after fixing the send in http_loader
|
||||||
|
// For now, the id of the first pipeline is passed
|
||||||
|
handle_network_event(actors.clone(), connections, &actor_pipelines, &mut actor_requests,
|
||||||
|
PipelineId(0), request_id, network_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for connection in accepted_connections.iter_mut() {
|
for connection in accepted_connections.iter_mut() {
|
||||||
let _ = connection.shutdown(Shutdown::Both);
|
let _ = connection.shutdown(Shutdown::Both);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,8 @@ path = "../msg"
|
||||||
[dependencies.util]
|
[dependencies.util]
|
||||||
path = "../util"
|
path = "../util"
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
url = "0.2.16"
|
|
||||||
hyper = "0.3"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time = "*"
|
time = "*"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
|
url = "*"
|
||||||
|
hyper = "*"
|
||||||
|
|
|
@ -32,3 +32,4 @@ regex = "0.1.14"
|
||||||
regex_macros = "0.1.8"
|
regex_macros = "0.1.8"
|
||||||
hyper = "0.3"
|
hyper = "0.3"
|
||||||
flate2 = "0.2.0"
|
flate2 = "0.2.0"
|
||||||
|
uuid = "*"
|
||||||
|
|
|
@ -143,7 +143,7 @@ reason: \"certificate verify failed\" }]))";
|
||||||
) => {
|
) => {
|
||||||
let mut image = resources_dir_path();
|
let mut image = resources_dir_path();
|
||||||
image.push("badcert.html");
|
image.push("badcert.html");
|
||||||
let load_data = LoadData::new(Url::from_file_path(&*image).unwrap());
|
let load_data = LoadData::new(Url::from_file_path(&*image).unwrap(), None);
|
||||||
file_loader::factory(load_data, start_chan, classifier);
|
file_loader::factory(load_data, start_chan, classifier);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
@ -200,15 +200,6 @@ reason: \"certificate verify failed\" }]))";
|
||||||
info!("{:?}", load_data.data);
|
info!("{:?}", load_data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
let request_id = uuid::Uuid::new_v4().to_simple_string();
|
|
||||||
let net_event = NetworkEvent::HttpRequest(
|
|
||||||
load_data.url.clone(),
|
|
||||||
load_data.method.clone(),
|
|
||||||
load_data.headers.clone(),
|
|
||||||
load_data.data.clone()
|
|
||||||
);
|
|
||||||
devtools_chan.as_ref().map(|chan| chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id.clone(), net_event)));
|
|
||||||
|
|
||||||
// Avoid automatically sending request body if a redirect has occurred.
|
// Avoid automatically sending request body if a redirect has occurred.
|
||||||
let writer = match load_data.data {
|
let writer = match load_data.data {
|
||||||
Some(ref data) if iters == 1 => {
|
Some(ref data) if iters == 1 => {
|
||||||
|
@ -243,6 +234,18 @@ reason: \"certificate verify failed\" }]))";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Send an HttpRequest message to devtools with a unique request_id
|
||||||
|
// TODO: Do this only if load_data has some pipeline_id, and send the pipeline_id in the message
|
||||||
|
let request_id = uuid::Uuid::new_v4().to_simple_string();
|
||||||
|
if let Some(ref chan) = devtools_chan {
|
||||||
|
let net_event = NetworkEvent::HttpRequest(load_data.url.clone(),
|
||||||
|
load_data.method.clone(),
|
||||||
|
load_data.headers.clone(),
|
||||||
|
load_data.data.clone());
|
||||||
|
chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id.clone(), net_event)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let mut response = match writer.send() {
|
let mut response = match writer.send() {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -341,9 +344,12 @@ reason: \"certificate verify failed\" }]))";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Http loader Response");
|
// Send an HttpResponse message to devtools with the corresponding request_id
|
||||||
|
// TODO: Send this message only if load_data has a pipeline_id that is not None
|
||||||
|
if let Some(ref chan) = devtools_chan {
|
||||||
let net_event_response = NetworkEvent::HttpResponse(metadata.headers.clone(), metadata.status.clone(), None);
|
let net_event_response = NetworkEvent::HttpResponse(metadata.headers.clone(), metadata.status.clone(), None);
|
||||||
devtools_chan.as_ref().map(|chan| chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id, net_event_response)));
|
chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id, net_event_response)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
match encoding_str {
|
match encoding_str {
|
||||||
Some(encoding) => {
|
Some(encoding) => {
|
||||||
|
|
|
@ -306,7 +306,7 @@ impl ImageCache {
|
||||||
pending_load.add_listener(image_listener);
|
pending_load.add_listener(image_listener);
|
||||||
e.insert(pending_load);
|
e.insert(pending_load);
|
||||||
|
|
||||||
let load_data = LoadData::new(url.clone());
|
let load_data = LoadData::new(url.clone(), None);
|
||||||
let listener = box ResourceListener {
|
let listener = box ResourceListener {
|
||||||
url: url,
|
url: url,
|
||||||
sender: self.progress_sender.clone(),
|
sender: self.progress_sender.clone(),
|
||||||
|
|
|
@ -16,6 +16,9 @@ git = "https://github.com/servo/rust-png"
|
||||||
[dependencies.util]
|
[dependencies.util]
|
||||||
path = "../util"
|
path = "../util"
|
||||||
|
|
||||||
|
[dependencies.msg]
|
||||||
|
path = "../msg"
|
||||||
|
|
||||||
[dependencies.stb_image]
|
[dependencies.stb_image]
|
||||||
git = "https://github.com/servo/rust-stb-image"
|
git = "https://github.com/servo/rust-stb-image"
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,13 @@ extern crate png;
|
||||||
extern crate stb_image;
|
extern crate stb_image;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
extern crate util;
|
extern crate util;
|
||||||
|
extern crate msg;
|
||||||
|
|
||||||
use hyper::header::{ContentType, Headers};
|
use hyper::header::{ContentType, Headers};
|
||||||
use hyper::http::RawStatus;
|
use hyper::http::RawStatus;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use hyper::mime::{Mime, Attr};
|
use hyper::mime::{Mime, Attr};
|
||||||
|
use msg::constellation_msg::{PipelineId};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
|
@ -47,10 +49,11 @@ pub struct LoadData {
|
||||||
pub preserved_headers: Headers,
|
pub preserved_headers: Headers,
|
||||||
pub data: Option<Vec<u8>>,
|
pub data: Option<Vec<u8>>,
|
||||||
pub cors: Option<ResourceCORSData>,
|
pub cors: Option<ResourceCORSData>,
|
||||||
|
pub pipeline_id: Option<PipelineId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoadData {
|
impl LoadData {
|
||||||
pub fn new(url: Url) -> LoadData {
|
pub fn new(url: Url, id: Option<PipelineId>) -> LoadData {
|
||||||
LoadData {
|
LoadData {
|
||||||
url: url,
|
url: url,
|
||||||
method: Method::Get,
|
method: Method::Get,
|
||||||
|
@ -58,6 +61,7 @@ impl LoadData {
|
||||||
preserved_headers: Headers::new(),
|
preserved_headers: Headers::new(),
|
||||||
data: None,
|
data: None,
|
||||||
cors: None,
|
cors: None,
|
||||||
|
pipeline_id: id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +216,7 @@ pub enum ProgressMsg {
|
||||||
pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
|
pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
|
||||||
-> Result<(Metadata, Vec<u8>), String> {
|
-> Result<(Metadata, Vec<u8>), String> {
|
||||||
let (start_chan, start_port) = channel();
|
let (start_chan, start_port) = channel();
|
||||||
resource_task.send(ControlMsg::Load(LoadData::new(url), LoadConsumer::Channel(start_chan))).unwrap();
|
resource_task.send(ControlMsg::Load(LoadData::new(url, None), LoadConsumer::Channel(start_chan))).unwrap();
|
||||||
let response = start_port.recv().unwrap();
|
let response = start_port.recv().unwrap();
|
||||||
|
|
||||||
let mut buf = vec!();
|
let mut buf = vec!();
|
||||||
|
@ -228,7 +232,7 @@ pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
|
||||||
/// Load a URL asynchronously and iterate over chunks of bytes from the response.
|
/// Load a URL asynchronously and iterate over chunks of bytes from the response.
|
||||||
pub fn load_bytes_iter(resource_task: &ResourceTask, url: Url) -> (Metadata, ProgressMsgPortIterator) {
|
pub fn load_bytes_iter(resource_task: &ResourceTask, url: Url) -> (Metadata, ProgressMsgPortIterator) {
|
||||||
let (input_chan, input_port) = channel();
|
let (input_chan, input_port) = channel();
|
||||||
resource_task.send(ControlMsg::Load(LoadData::new(url), LoadConsumer::Channel(input_chan))).unwrap();
|
resource_task.send(ControlMsg::Load(LoadData::new(url, None), LoadConsumer::Channel(input_chan))).unwrap();
|
||||||
|
|
||||||
let response = input_port.recv().unwrap();
|
let response = input_port.recv().unwrap();
|
||||||
let iter = ProgressMsgPortIterator { progress_port: response.progress_port };
|
let iter = ProgressMsgPortIterator { progress_port: response.progress_port };
|
||||||
|
|
|
@ -515,7 +515,9 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap());
|
let global = self.global.root();
|
||||||
|
let pipeline_id = global.r().pipeline();
|
||||||
|
let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap(), Some(pipeline_id));
|
||||||
load_data.data = extracted;
|
load_data.data = extracted;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1358,6 +1358,7 @@ impl ScriptTask {
|
||||||
preserved_headers: load_data.headers,
|
preserved_headers: load_data.headers,
|
||||||
data: load_data.data,
|
data: load_data.data,
|
||||||
cors: None,
|
cors: None,
|
||||||
|
pipeline_id: Some(id),
|
||||||
}, LoadConsumer::Channel(input_chan))).unwrap();
|
}, LoadConsumer::Channel(input_chan))).unwrap();
|
||||||
|
|
||||||
let load_response = input_port.recv().unwrap();
|
let load_response = input_port.recv().unwrap();
|
||||||
|
|
6
components/servo/Cargo.lock
generated
6
components/servo/Cargo.lock
generated
|
@ -183,9 +183,11 @@ name = "devtools"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -193,6 +195,7 @@ dependencies = [
|
||||||
name = "devtools_traits"
|
name = "devtools_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -756,6 +759,7 @@ name = "net"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"devtools_traits 0.0.1",
|
||||||
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -768,6 +772,7 @@ dependencies = [
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
"uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -788,6 +793,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"msg 0.0.1",
|
||||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -22,4 +22,4 @@ git = "https://github.com/jgraham/webdriver-rust.git"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-serialize = "0.3.4"
|
rustc-serialize = "0.3.4"
|
||||||
url = "0.2.16"
|
url = "0.2.16"
|
||||||
uuid = "0.1.11"
|
uuid = "*"
|
6
ports/cef/Cargo.lock
generated
6
ports/cef/Cargo.lock
generated
|
@ -192,9 +192,11 @@ name = "devtools"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -202,6 +204,7 @@ dependencies = [
|
||||||
name = "devtools_traits"
|
name = "devtools_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -758,6 +761,7 @@ name = "net"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"devtools_traits 0.0.1",
|
||||||
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -770,6 +774,7 @@ dependencies = [
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
"uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -778,6 +783,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"msg 0.0.1",
|
||||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
6
ports/gonk/Cargo.lock
generated
6
ports/gonk/Cargo.lock
generated
|
@ -175,9 +175,11 @@ name = "devtools"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -185,6 +187,7 @@ dependencies = [
|
||||||
name = "devtools_traits"
|
name = "devtools_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -731,6 +734,7 @@ name = "net"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"devtools_traits 0.0.1",
|
||||||
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -743,6 +747,7 @@ dependencies = [
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
"uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -751,6 +756,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"msg 0.0.1",
|
||||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||||
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -103,7 +103,7 @@ impl Browser {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a Servo instance.
|
// Create a Servo instance.
|
||||||
let resource_task = new_resource_task(opts.user_agent.clone());
|
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||||
|
|
||||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||||
let font_cache_task = FontCacheTask::new(resource_task.clone());
|
let font_cache_task = FontCacheTask::new(resource_task.clone());
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn assert_parse(url: &'static str,
|
||||||
use net::data_loader::load;
|
use net::data_loader::load;
|
||||||
|
|
||||||
let (start_chan, start_port) = channel();
|
let (start_chan, start_port) = channel();
|
||||||
load(LoadData::new(Url::parse(url).unwrap()), Channel(start_chan));
|
load(LoadData::new(Url::parse(url).unwrap(), None), Channel(start_chan));
|
||||||
|
|
||||||
let response = start_port.recv().unwrap();
|
let response = start_port.recv().unwrap();
|
||||||
assert_eq!(&response.metadata.content_type, &content_type);
|
assert_eq!(&response.metadata.content_type, &content_type);
|
||||||
|
|
|
@ -14,16 +14,16 @@ use url::Url;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_exit() {
|
fn test_exit() {
|
||||||
let resource_task = new_resource_task(None);
|
let resource_task = new_resource_task(None, None);
|
||||||
resource_task.send(ControlMsg::Exit).unwrap();
|
resource_task.send(ControlMsg::Exit).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bad_scheme() {
|
fn test_bad_scheme() {
|
||||||
let resource_task = new_resource_task(None);
|
let resource_task = new_resource_task(None, None);
|
||||||
let (start_chan, start) = channel();
|
let (start_chan, start) = channel();
|
||||||
let url = Url::parse("bogus://whatever").unwrap();
|
let url = Url::parse("bogus://whatever").unwrap();
|
||||||
resource_task.send(ControlMsg::Load(LoadData::new(url), LoadConsumer::Channel(start_chan))).unwrap();
|
resource_task.send(ControlMsg::Load(LoadData::new(url, None), LoadConsumer::Channel(start_chan))).unwrap();
|
||||||
let response = start.recv().unwrap();
|
let response = start.recv().unwrap();
|
||||||
match response.progress_port.recv().unwrap() {
|
match response.progress_port.recv().unwrap() {
|
||||||
ProgressMsg::Done(result) => { assert!(result.is_err()) }
|
ProgressMsg::Done(result) => { assert!(result.is_err()) }
|
||||||
|
@ -170,10 +170,10 @@ fn test_replace_hosts() {
|
||||||
let port = listener.local_addr().unwrap().port();
|
let port = listener.local_addr().unwrap().port();
|
||||||
|
|
||||||
//Start the resource task and make a request to our TCP server
|
//Start the resource task and make a request to our TCP server
|
||||||
let resource_task = new_resource_task(None);
|
let resource_task = new_resource_task(None, None);
|
||||||
let (start_chan, _) = channel();
|
let (start_chan, _) = channel();
|
||||||
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
|
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
|
||||||
resource_task.send(ControlMsg::Load(replace_hosts(LoadData::new(url), host_table), LoadConsumer::Channel(start_chan))).unwrap();
|
resource_task.send(ControlMsg::Load(replace_hosts(LoadData::new(url, None), host_table), LoadConsumer::Channel(start_chan))).unwrap();
|
||||||
|
|
||||||
match listener.accept() {
|
match listener.accept() {
|
||||||
Ok(..) => assert!(true, "received request"),
|
Ok(..) => assert!(true, "received request"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue