diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-10-13 17:01:24 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-10-14 14:18:03 +0200 |
commit | e134871a95c43e4938fddb48b5b8398f896178ed (patch) | |
tree | a3d8334d91f777231b617d0ae42b252392a23116 /components/net/fetch/methods.rs | |
parent | 92f1cbcbe3550c3456e5db873c80ef086b72991a (diff) | |
download | servo-e134871a95c43e4938fddb48b5b8398f896178ed.tar.gz servo-e134871a95c43e4938fddb48b5b8398f896178ed.zip |
Implement blob url support in the fetch stack.
Diffstat (limited to 'components/net/fetch/methods.rs')
-rw-r--r-- | components/net/fetch/methods.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 717ddb784e1..0d5b2d2835e 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -2,6 +2,7 @@ * 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/. */ +use blob_loader::load_blob_sync; use connector::create_http_connector; use data_loader::decode; use devtools_traits::DevtoolsControlMsg; @@ -464,7 +465,29 @@ fn basic_fetch<UI: 'static + UIProvider>(request: Rc<Request>, } }, - "blob" | "ftp" => { + "blob" => { + println!("Loading blob {}", url.as_str()); + // Step 2. + if *request.method.borrow() != Method::Get { + return Response::network_error(); + } + + match load_blob_sync(url.clone(), context.filemanager.clone()) { + Ok((headers, bytes)) => { + let mut response = Response::new(); + response.url = Some(url.clone()); + response.headers = headers; + *response.body.lock().unwrap() = ResponseBody::Done(bytes); + response + }, + Err(e) => { + debug!("Failed to load {}: {:?}", url, e); + Response::network_error() + }, + } + }, + + "ftp" => { // XXXManishearth handle these panic!("Unimplemented scheme for Fetch") }, |