aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/fetch/methods.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/net/fetch/methods.rs')
-rw-r--r--components/net/fetch/methods.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs
index 976b1e0b5ee..7c1cb5e3416 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 data_loader::decode;
use fetch::cors_cache::{BasicCORSCache, CORSCache, CacheRequestDetails};
use http_loader::{NetworkHttpRequestFactory, create_http_connector, obtain_response};
use hyper::header::{Accept, CacheControl, IfMatch, IfRange, IfUnmodifiedSince, Location};
@@ -305,7 +306,23 @@ fn basic_fetch(request: Rc<Request>) -> Response {
http_fetch(request.clone(), BasicCORSCache::new(), false, false, false)
},
- "blob" | "data" | "file" | "ftp" => {
+ "data" => {
+ if *request.method.borrow() == Method::Get {
+ match decode(&url) {
+ Ok((mime, bytes)) => {
+ let mut response = Response::new();
+ *response.body.lock().unwrap() = ResponseBody::Done(bytes);
+ response.headers.set(ContentType(mime));
+ response
+ },
+ Err(_) => Response::network_error()
+ }
+ } else {
+ Response::network_error()
+ }
+ },
+
+ "blob" | "file" | "ftp" => {
// XXXManishearth handle these
panic!("Unimplemented scheme for Fetch")
},