aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/devtools/Cargo.toml2
-rw-r--r--components/devtools/actors/network_event.rs165
-rw-r--r--components/devtools/lib.rs105
-rw-r--r--components/devtools_traits/Cargo.toml5
-rw-r--r--components/devtools_traits/lib.rs14
-rw-r--r--components/net/Cargo.toml4
-rw-r--r--components/net/http_loader.rs30
-rw-r--r--components/net/image_cache_task.rs2
-rw-r--r--components/net/lib.rs2
-rw-r--r--components/net/resource_task.rs12
-rw-r--r--components/net_traits/Cargo.toml3
-rw-r--r--components/net_traits/lib.rs10
-rw-r--r--components/script/dom/xmlhttprequest.rs4
-rw-r--r--components/script/script_task.rs1
-rw-r--r--components/servo/Cargo.lock6
-rw-r--r--components/servo/lib.rs2
-rw-r--r--components/webdriver_server/Cargo.toml2
-rw-r--r--ports/cef/Cargo.lock6
-rw-r--r--ports/gonk/Cargo.lock6
-rw-r--r--ports/gonk/src/lib.rs2
-rw-r--r--tests/unit/net/data_loader.rs2
-rw-r--r--tests/unit/net/resource_task.rs10
22 files changed, 367 insertions, 28 deletions
diff --git a/components/devtools/Cargo.toml b/components/devtools/Cargo.toml
index 6503aa125cb..5fe447183ee 100644
--- a/components/devtools/Cargo.toml
+++ b/components/devtools/Cargo.toml
@@ -19,3 +19,5 @@ path = "../util"
[dependencies]
time = "*"
rustc-serialize = "0.3"
+url = "*"
+hyper = "*"
diff --git a/components/devtools/actors/network_event.rs b/components/devtools/actors/network_event.rs
new file mode 100644
index 00000000000..28a6acc18f0
--- /dev/null
+++ b/components/devtools/actors/network_event.rs
@@ -0,0 +1,165 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * 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).
+/// Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo.
+
+extern crate hyper;
+
+use actor::{Actor, ActorRegistry};
+use protocol::JsonPacketStream;
+use rustc_serialize::json;
+use std::net::TcpStream;
+use url::Url;
+use hyper::header::Headers;
+use hyper::http::RawStatus;
+use hyper::method::Method;
+
+struct HttpRequest {
+ url: String,
+ method: Method,
+ headers: Headers,
+ body: Option<Vec<u8>>,
+}
+
+struct HttpResponse {
+ headers: Option<Headers>,
+ status: Option<RawStatus>,
+ body: Option<Vec<u8>>
+}
+
+pub struct NetworkEventActor {
+ pub name: String,
+ request: HttpRequest,
+ response: HttpResponse,
+}
+
+#[derive(RustcEncodable)]
+pub struct EventActor {
+ pub actor: String,
+ pub url: String,
+ pub method: String,
+ pub startedDateTime: String,
+ pub isXHR: bool,
+ pub private: bool
+}
+
+#[derive(RustcEncodable)]
+pub struct ResponseStartMsg {
+ pub httpVersion: String,
+ pub remoteAddress: String,
+ pub remotePort: u32,
+ pub status: String,
+ pub statusText: String,
+ pub headersSize: u32,
+ pub discardResponseBody: bool,
+}
+
+#[derive(RustcEncodable)]
+struct GetRequestHeadersReply {
+ from: String,
+ headers: Vec<String>,
+ headerSize: u8,
+ rawHeaders: String
+}
+
+impl Actor for NetworkEventActor {
+ fn name(&self) -> String {
+ self.name.clone()
+ }
+
+ fn handle_message(&self,
+ _registry: &ActorRegistry,
+ msg_type: &str,
+ _msg: &json::Object,
+ stream: &mut TcpStream) -> Result<bool, ()> {
+ Ok(match msg_type {
+ "getRequestHeaders" => {
+ // TODO: Pass the correct values for headers, headerSize, rawHeaders
+ let msg = GetRequestHeadersReply {
+ from: self.name(),
+ headers: Vec::new(),
+ headerSize: 10,
+ rawHeaders: "Raw headers".to_string(),
+ };
+ stream.write_json_packet(&msg);
+ true
+ }
+ "getRequestCookies" => {
+ false
+ }
+ "getRequestPostData" => {
+ false
+ }
+ "getResponseHeaders" => {
+ false
+ }
+ "getResponseCookies" => {
+ false
+ }
+ "getResponseContent" => {
+ false
+ }
+ _ => false
+ })
+ }
+}
+
+impl NetworkEventActor {
+ pub fn new(name: String) -> NetworkEventActor {
+ NetworkEventActor {
+ name: name,
+ request: HttpRequest {
+ url: String::new(),
+ method: Method::Get,
+ headers: Headers::new(),
+ body: None
+ },
+ response: HttpResponse {
+ headers: None,
+ status: None,
+ body: None,
+ }
+ }
+ }
+
+ pub fn add_request(&mut self, url: Url, method: Method, headers: Headers, body: Option<Vec<u8>>) {
+ self.request.url = url.serialize();
+ self.request.method = method.clone();
+ self.request.headers = headers.clone();
+ self.request.body = body;
+ }
+
+ pub fn add_response(&mut self, headers: Option<Headers>, status: Option<RawStatus>, body: Option<Vec<u8>>) {
+ self.response.headers = headers.clone();
+ self.response.status = status.clone();
+ self.response.body = body.clone();
+ }
+
+ pub fn get_event_actor(&self) -> EventActor {
+ // TODO: Send the correct values for startedDateTime, isXHR, private
+ EventActor {
+ actor: self.name(),
+ url: self.request.url.clone(),
+ method: format!("{}", self.request.method),
+ startedDateTime: "2015-04-22T20:47:08.545Z".to_string(),
+ isXHR: false,
+ private: false,
+ }
+ }
+
+ pub fn get_response_start(&self) -> ResponseStartMsg {
+ // TODO: Send the correct values for all these fields.
+ // This is a fake message.
+ ResponseStartMsg {
+ httpVersion: "HTTP/1.1".to_string(),
+ remoteAddress: "63.245.217.43".to_string(),
+ remotePort: 443,
+ status: "200".to_string(),
+ statusText: "OK".to_string(),
+ headersSize: 337,
+ discardResponseBody: true
+ }
+ }
+}
diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs
index 348c4fdeb12..c0b50147699 100644
--- a/components/devtools/lib.rs
+++ b/components/devtools/lib.rs
@@ -25,9 +25,12 @@ extern crate rustc_serialize;
extern crate msg;
extern crate time;
extern crate util;
+extern crate hyper;
+extern crate url;
use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
+use actors::network_event::{NetworkEventActor, EventActor, ResponseStartMsg};
use actors::worker::WorkerActor;
use actors::inspector::InspectorActor;
use actors::root::RootActor;
@@ -35,7 +38,7 @@ use actors::tab::TabActor;
use actors::timeline::TimelineActor;
use protocol::JsonPacketStream;
-use devtools_traits::{ConsoleMessage, DevtoolsControlMsg};
+use devtools_traits::{ConsoleMessage, DevtoolsControlMsg, NetworkEvent};
use devtools_traits::{DevtoolsPageInfo, DevtoolScriptControlMsg};
use msg::constellation_msg::{PipelineId, WorkerId};
use util::task::spawn_named;
@@ -43,6 +46,7 @@ use util::task::spawn_named;
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::HashMap;
+use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::error::Error;
use std::sync::mpsc::{channel, Receiver, Sender, RecvError};
use std::net::{TcpListener, TcpStream, Shutdown};
@@ -60,6 +64,7 @@ mod actors {
pub mod tab;
pub mod timeline;
pub mod worker;
+ pub mod network_event;
}
mod protocol;
@@ -80,6 +85,21 @@ struct ConsoleMsg {
columnNumber: u32,
}
+#[derive(RustcEncodable)]
+struct NetworkEventMsg {
+ from: String,
+ __type__: String,
+ eventActor: EventActor,
+}
+
+#[derive(RustcEncodable)]
+struct NetworkEventUpdateMsg {
+ from: String,
+ __type__: String,
+ updateType: String,
+ response: ResponseStartMsg,
+}
+
/// Spin up a devtools server that listens for connections on the specified port.
pub fn start_server(port: u16) -> Sender<DevtoolsControlMsg> {
let (sender, receiver) = channel();
@@ -111,6 +131,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
let mut accepted_connections: Vec<TcpStream> = Vec::new();
let mut actor_pipelines: HashMap<PipelineId, String> = HashMap::new();
+ let mut actor_requests: HashMap<String, String> = HashMap::new();
let mut actor_workers: HashMap<(PipelineId, WorkerId), String> = HashMap::new();
@@ -252,6 +273,76 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
return console_actor_name;
}
+ fn handle_network_event(actors: Arc<Mutex<ActorRegistry>>,
+ mut connections: Vec<TcpStream>,
+ actor_pipelines: &HashMap<PipelineId, String>,
+ actor_requests: &mut HashMap<String, String>,
+ pipeline_id: PipelineId,
+ request_id: String,
+ network_event: NetworkEvent) {
+
+ 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 mut actors = actors.lock().unwrap();
+ let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
+
+ match network_event {
+ NetworkEvent::HttpRequest(url, method, headers, body) => {
+ //Store the request information in the actor
+ actor.add_request(url, method, headers, body);
+
+ //Send a networkEvent message to the client
+ let msg = NetworkEventMsg {
+ from: console_actor_name,
+ __type__: "networkEvent".to_string(),
+ eventActor: actor.get_event_actor(),
+ };
+ for stream in connections.iter_mut() {
+ stream.write_json_packet(&msg);
+ }
+ }
+ NetworkEvent::HttpResponse(headers, status, body) => {
+ //Store the response information in the actor
+ actor.add_response(headers, status, body);
+
+ //Send a networkEventUpdate (responseStart) to the client
+ let msg = NetworkEventUpdateMsg {
+ from: netevent_actor_name,
+ __type__: "networkEventUpdate".to_string(),
+ updateType: "responseStart".to_string(),
+ response: actor.get_response_start()
+ };
+
+ for stream in connections.iter_mut() {
+ 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
+ }
+ }
+ }
+
spawn_named("DevtoolsClientAcceptor".to_owned(), move || {
// accept connections and process them, spawning a new task for each one
for stream in listener.incoming() {
@@ -276,9 +367,19 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
Ok(DevtoolsControlMsg::SendConsoleMessage(id, console_message)) =>
handle_console_message(actors.clone(), id, console_message,
&actor_pipelines),
+ Ok(DevtoolsControlMsg::NetworkEventMessage(request_id, network_event)) => {
+ // copy the accepted_connections vector
+ let mut connections = Vec::<TcpStream>::new();
+ for stream in accepted_connections.iter() {
+ connections.push(stream.try_clone().unwrap());
+ }
+ //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() {
let _ = connection.shutdown(Shutdown::Both);
}
diff --git a/components/devtools_traits/Cargo.toml b/components/devtools_traits/Cargo.toml
index 0788d874c3a..05cc4a9f283 100644
--- a/components/devtools_traits/Cargo.toml
+++ b/components/devtools_traits/Cargo.toml
@@ -14,8 +14,7 @@ path = "../msg"
path = "../util"
[dependencies]
-url = "0.2.16"
-
-[dependencies]
time = "*"
rustc-serialize = "0.3"
+url = "*"
+hyper = "*"
diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs
index 9be18bf5e19..4ab74a9e1de 100644
--- a/components/devtools_traits/lib.rs
+++ b/components/devtools_traits/lib.rs
@@ -14,6 +14,7 @@
extern crate msg;
extern crate rustc_serialize;
extern crate url;
+extern crate hyper;
extern crate util;
extern crate time;
@@ -22,6 +23,10 @@ use msg::constellation_msg::{PipelineId, WorkerId};
use util::str::DOMString;
use url::Url;
+use hyper::header::Headers;
+use hyper::http::RawStatus;
+use hyper::method::Method;
+
use std::net::TcpStream;
use std::sync::mpsc::{Sender, Receiver};
@@ -41,7 +46,8 @@ pub enum DevtoolsControlMsg {
AddClient(TcpStream),
NewGlobal((PipelineId, Option<WorkerId>), Sender<DevtoolScriptControlMsg>, DevtoolsPageInfo),
SendConsoleMessage(PipelineId, ConsoleMessage),
- ServerExitMsg
+ ServerExitMsg,
+ NetworkEventMessage(String, NetworkEvent),
}
/// Serialized JS return values
@@ -145,6 +151,12 @@ pub enum ConsoleMessage {
//WarnMessage(String),
}
+#[derive(Clone)]
+pub enum NetworkEvent {
+ HttpRequest(Url, Method, Headers, Option<Vec<u8>>),
+ HttpResponse(Option<Headers>, Option<RawStatus>, Option<Vec<u8>>)
+}
+
impl TimelineMarker {
pub fn new(name: String, metadata: TracingMetadata) -> TimelineMarker {
TimelineMarker {
diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml
index cb4c6038b43..3fb0f5b0a7b 100644
--- a/components/net/Cargo.toml
+++ b/components/net/Cargo.toml
@@ -13,6 +13,9 @@ path = "../net_traits"
[dependencies.util]
path = "../util"
+[dependencies.devtools_traits]
+path = "../devtools_traits"
+
[dependencies.geom]
git = "https://github.com/servo/rust-geom"
@@ -29,3 +32,4 @@ regex = "0.1.14"
regex_macros = "0.1.8"
hyper = "0.3"
flate2 = "0.2.0"
+uuid = "*"
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs
index dec8727daad..bc3b72dddf0 100644
--- a/components/net/http_loader.rs
+++ b/components/net/http_loader.rs
@@ -4,6 +4,7 @@
use net_traits::{ControlMsg, CookieSource, LoadData, Metadata, LoadConsumer};
use net_traits::ProgressMsg::{Payload, Done};
+use devtools_traits::{DevtoolsControlMsg, NetworkEvent};
use mime_classifier::MIMEClassifier;
use resource_task::{start_sending_opt, start_sending_sniffed_opt};
@@ -28,13 +29,14 @@ use util::resource_files::resources_dir_path;
use util::opts;
use url::{Url, UrlParser};
+use uuid;
use std::borrow::ToOwned;
use std::boxed::FnBox;
-pub fn factory(cookies_chan: Sender<ControlMsg>)
+pub fn factory(cookies_chan: Sender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>)
-> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> {
box move |load_data, senders, classifier| {
- spawn_named("http_loader".to_owned(), move || load(load_data, senders, classifier, cookies_chan))
+ spawn_named("http_loader".to_owned(), move || load(load_data, senders, classifier, cookies_chan, devtools_chan))
}
}
@@ -66,7 +68,8 @@ fn read_block<R: Read>(reader: &mut R) -> Result<ReadResult, ()> {
}
}
-fn load(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Arc<MIMEClassifier>, cookies_chan: Sender<ControlMsg>) {
+fn load(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Arc<MIMEClassifier>,
+ cookies_chan: Sender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>) {
// FIXME: At the time of writing this FIXME, servo didn't have any central
// location for configuration. If you're reading this and such a
// repository DOES exist, please update this constant to use it.
@@ -140,7 +143,7 @@ reason: \"certificate verify failed\" }]))";
) => {
let mut image = resources_dir_path();
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);
return;
},
@@ -231,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() {
Ok(r) => r,
Err(e) => {
@@ -329,6 +344,13 @@ reason: \"certificate verify failed\" }]))";
}
}
+ // 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);
+ chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id, net_event_response)).unwrap();
+ }
+
match encoding_str {
Some(encoding) => {
if encoding == "gzip" {
diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_task.rs
index d4e7f3c98b6..b0b488386bf 100644
--- a/components/net/image_cache_task.rs
+++ b/components/net/image_cache_task.rs
@@ -306,7 +306,7 @@ impl ImageCache {
pending_load.add_listener(image_listener);
e.insert(pending_load);
- let load_data = LoadData::new(url.clone());
+ let load_data = LoadData::new(url.clone(), None);
let listener = box ResourceListener {
url: url,
sender: self.progress_sender.clone(),
diff --git a/components/net/lib.rs b/components/net/lib.rs
index 8ab60ead069..8379211b36f 100644
--- a/components/net/lib.rs
+++ b/components/net/lib.rs
@@ -16,6 +16,7 @@
extern crate net_traits;
extern crate cookie as cookie_rs;
+extern crate devtools_traits;
extern crate collections;
extern crate flate2;
extern crate geom;
@@ -28,6 +29,7 @@ extern crate rustc_serialize;
extern crate util;
extern crate time;
extern crate url;
+extern crate uuid;
extern crate regex;
diff --git a/components/net/resource_task.rs b/components/net/resource_task.rs
index cac46cbce8b..ac463503a1b 100644
--- a/components/net/resource_task.rs
+++ b/components/net/resource_task.rs
@@ -18,6 +18,7 @@ use net_traits::ProgressMsg::Done;
use util::opts;
use util::task::spawn_named;
+use devtools_traits::{DevtoolsControlMsg};
use hyper::header::{ContentType, Header, SetCookie, UserAgent};
use hyper::mime::{Mime, TopLevel, SubLevel};
@@ -31,6 +32,7 @@ use std::str::FromStr;
use std::sync::Arc;
use std::sync::mpsc::{channel, Receiver, Sender};
+
static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None;
pub fn global_init() {
@@ -136,11 +138,11 @@ pub fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result
}
/// Create a ResourceTask
-pub fn new_resource_task(user_agent: Option<String>) -> ResourceTask {
+pub fn new_resource_task(user_agent: Option<String>, devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceTask {
let (setup_chan, setup_port) = channel();
let setup_chan_clone = setup_chan.clone();
spawn_named("ResourceManager".to_owned(), move || {
- ResourceManager::new(setup_port, user_agent, setup_chan_clone).start();
+ ResourceManager::new(setup_port, user_agent, setup_chan_clone, devtools_chan).start();
});
setup_chan
}
@@ -185,17 +187,19 @@ struct ResourceManager {
cookie_storage: CookieStorage,
resource_task: Sender<ControlMsg>,
mime_classifier: Arc<MIMEClassifier>,
+ devtools_chan: Option<Sender<DevtoolsControlMsg>>
}
impl ResourceManager {
fn new(from_client: Receiver<ControlMsg>, user_agent: Option<String>,
- resource_task: Sender<ControlMsg>) -> ResourceManager {
+ resource_task: Sender<ControlMsg>, devtools_channel: Option<Sender<DevtoolsControlMsg>>) -> ResourceManager {
ResourceManager {
from_client: from_client,
user_agent: user_agent,
cookie_storage: CookieStorage::new(),
resource_task: resource_task,
mime_classifier: Arc::new(MIMEClassifier::new()),
+ devtools_chan: devtools_channel
}
}
}
@@ -246,7 +250,7 @@ impl ResourceManager {
let loader = match &*load_data.url.scheme {
"file" => from_factory(file_loader::factory),
- "http" | "https" | "view-source" => http_loader::factory(self.resource_task.clone()),
+ "http" | "https" | "view-source" => http_loader::factory(self.resource_task.clone(), self.devtools_chan.clone()),
"data" => from_factory(data_loader::factory),
"about" => from_factory(about_loader::factory),
_ => {
diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml
index bd336eb2a9c..6f82ca385c6 100644
--- a/components/net_traits/Cargo.toml
+++ b/components/net_traits/Cargo.toml
@@ -16,6 +16,9 @@ git = "https://github.com/servo/rust-png"
[dependencies.util]
path = "../util"
+[dependencies.msg]
+path = "../msg"
+
[dependencies.stb_image]
git = "https://github.com/servo/rust-stb-image"
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index ba9daea4cf4..c5f5fb884e8 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -16,11 +16,13 @@ extern crate png;
extern crate stb_image;
extern crate url;
extern crate util;
+extern crate msg;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::mime::{Mime, Attr};
+use msg::constellation_msg::{PipelineId};
use url::Url;
use std::sync::mpsc::{channel, Receiver, Sender};
@@ -47,10 +49,11 @@ pub struct LoadData {
pub preserved_headers: Headers,
pub data: Option<Vec<u8>>,
pub cors: Option<ResourceCORSData>,
+ pub pipeline_id: Option<PipelineId>,
}
impl LoadData {
- pub fn new(url: Url) -> LoadData {
+ pub fn new(url: Url, id: Option<PipelineId>) -> LoadData {
LoadData {
url: url,
method: Method::Get,
@@ -58,6 +61,7 @@ impl LoadData {
preserved_headers: Headers::new(),
data: None,
cors: None,
+ pipeline_id: id,
}
}
}
@@ -212,7 +216,7 @@ pub enum ProgressMsg {
pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
-> Result<(Metadata, Vec<u8>), String> {
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 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.
pub fn load_bytes_iter(resource_task: &ResourceTask, url: Url) -> (Metadata, ProgressMsgPortIterator) {
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 iter = ProgressMsgPortIterator { progress_port: response.progress_port };
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 4e038609fef..99d412ee8b7 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -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;
#[inline]
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 5e776d4db0f..5efbb6a1deb 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -1358,6 +1358,7 @@ impl ScriptTask {
preserved_headers: load_data.headers,
data: load_data.data,
cors: None,
+ pipeline_id: Some(id),
}, LoadConsumer::Channel(input_chan))).unwrap();
let load_response = input_port.recv().unwrap();
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 4748de71fca..12bc45b7375 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -183,9 +183,11 @@ name = "devtools"
version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
+ "url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
@@ -193,6 +195,7 @@ dependencies = [
name = "devtools_traits"
version = "0.0.1"
dependencies = [
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
@@ -756,6 +759,7 @@ name = "net"
version = "0.0.1"
dependencies = [
"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)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
+ "uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -788,6 +793,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"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)",
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index f3837112a82..df86056cace 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -155,7 +155,7 @@ fn create_constellation(opts: opts::Opts,
use std::env;
// 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 font_cache_task = FontCacheTask::new(resource_task.clone());
diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml
index 17fa3188e78..c96220c4516 100644
--- a/components/webdriver_server/Cargo.toml
+++ b/components/webdriver_server/Cargo.toml
@@ -22,4 +22,4 @@ git = "https://github.com/jgraham/webdriver-rust.git"
[dependencies]
rustc-serialize = "0.3.4"
url = "0.2.16"
-uuid = "0.1.11" \ No newline at end of file
+uuid = "*" \ No newline at end of file
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 2671a8cdc53..499175ca490 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -192,9 +192,11 @@ name = "devtools"
version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
+ "url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
@@ -202,6 +204,7 @@ dependencies = [
name = "devtools_traits"
version = "0.0.1"
dependencies = [
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
@@ -758,6 +761,7 @@ name = "net"
version = "0.0.1"
dependencies = [
"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)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
+ "uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -778,6 +783,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"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)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 6d8e591a0ba..8d0bc47a03e 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -175,9 +175,11 @@ name = "devtools"
version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
+ "url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
@@ -185,6 +187,7 @@ dependencies = [
name = "devtools_traits"
version = "0.0.1"
dependencies = [
+ "hyper 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"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)",
@@ -731,6 +734,7 @@ name = "net"
version = "0.0.1"
dependencies = [
"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)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
+ "uuid 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -751,6 +756,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"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)",
"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)",
diff --git a/ports/gonk/src/lib.rs b/ports/gonk/src/lib.rs
index d7a85e4dde2..3174c5294ee 100644
--- a/ports/gonk/src/lib.rs
+++ b/ports/gonk/src/lib.rs
@@ -103,7 +103,7 @@ impl Browser {
});
// 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 font_cache_task = FontCacheTask::new(resource_task.clone());
diff --git a/tests/unit/net/data_loader.rs b/tests/unit/net/data_loader.rs
index 517788a0344..b641b58d06a 100644
--- a/tests/unit/net/data_loader.rs
+++ b/tests/unit/net/data_loader.rs
@@ -20,7 +20,7 @@ fn assert_parse(url: &'static str,
use net::data_loader::load;
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();
assert_eq!(&response.metadata.content_type, &content_type);
diff --git a/tests/unit/net/resource_task.rs b/tests/unit/net/resource_task.rs
index 986c11b341e..9690ae2473d 100644
--- a/tests/unit/net/resource_task.rs
+++ b/tests/unit/net/resource_task.rs
@@ -14,16 +14,16 @@ use url::Url;
#[test]
fn test_exit() {
- let resource_task = new_resource_task(None);
+ let resource_task = new_resource_task(None, None);
resource_task.send(ControlMsg::Exit).unwrap();
}
#[test]
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 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();
match response.progress_port.recv().unwrap() {
ProgressMsg::Done(result) => { assert!(result.is_err()) }
@@ -170,10 +170,10 @@ fn test_replace_hosts() {
let port = listener.local_addr().unwrap().port();
//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 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() {
Ok(..) => assert!(true, "received request"),