aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/net/fetch/request.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2014-08-23 12:13:59 +0530
committerManish Goregaokar <manishsmail@gmail.com>2014-08-23 12:13:59 +0530
commit8cd572de958864f5ec964d676ffd06757722b800 (patch)
tree8713e139f2e6e062a8e7ff666ce6686f89ca0f09 /src/components/net/fetch/request.rs
parent2ce5b46bba2bf80890f3e7a305a4bc5a833ba477 (diff)
downloadservo-8cd572de958864f5ec964d676ffd06757722b800.tar.gz
servo-8cd572de958864f5ec964d676ffd06757722b800.zip
Add basic_fetch and a skeleton http_fetch
Diffstat (limited to 'src/components/net/fetch/request.rs')
-rw-r--r--src/components/net/fetch/request.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/net/fetch/request.rs b/src/components/net/fetch/request.rs
index 2de606a1a31..2dfd5572a97 100644
--- a/src/components/net/fetch/request.rs
+++ b/src/components/net/fetch/request.rs
@@ -5,6 +5,7 @@
use url::Url;
use http::method::{Get, Method};
use http::headers::request::HeaderCollection;
+use fetch::response::Response;
/// A [request context](http://fetch.spec.whatwg.org/#concept-request-context)
pub enum Context {
@@ -105,4 +106,41 @@ impl Request {
response_tainting: Basic
}
}
+
+ /// [Basic fetch](http://fetch.spec.whatwg.org#basic-fetch)
+ ///
+ pub fn basic_fetch(&mut self) -> Response {
+ match self.url.scheme.as_slice() {
+ "about" => match self.url.non_relative_scheme_data() {
+ Some(s) if s.as_slice() == "blank" => {
+ let mut response = Response::new();
+ let _ = response.headers.insert_raw("Content-Type".to_string(), b"text/html;charset=utf-8");
+ response
+ },
+ _ => Response::network_error()
+ },
+ "http" | "https" => {
+ self.http_fetch(false, false, false)
+ },
+ "blob" | "data" | "file" | "ftp" => {
+ // XXXManishearth handle these
+ fail!("Unimplemented scheme for Fetch")
+ },
+
+ _ => Response::network_error()
+ }
+ }
+ // [Basic fetch](http://fetch.spec.whatwg.org#http-fetch)
+ pub fn http_fetch(&mut self, _cors_flag: bool, cors_preflight_flag: bool, _authentication_fetch_flag: bool) -> Response {
+ let response = Response::new();
+ // TODO: Service worker fetch
+ // Step 3
+ // Substep 1
+ self.skip_service_worker = true;
+ // Substep 2
+ if cors_preflight_flag {
+ // XXXManishearth stuff goes here
+ }
+ response
+ }
}