diff options
author | Jeena Lee <ijeenalee@gmail.com> | 2016-07-19 18:38:02 -0700 |
---|---|---|
committer | Jeena Lee <ijeenalee@gmail.com> | 2016-08-12 15:39:40 -0700 |
commit | fabe2b8f7e5693d705427959a07a380d52c16e26 (patch) | |
tree | d15718e7f30f6182be6774c470e394b6bdc1cf18 /components/net_traits/request.rs | |
parent | b7facf41cbc7ba727666e95fd0c390d432d862fa (diff) | |
download | servo-fabe2b8f7e5693d705427959a07a380d52c16e26.tar.gz servo-fabe2b8f7e5693d705427959a07a380d52c16e26.zip |
Implement the Request API for the Fetch API.
This commit adds new files related to implementing the [Request
API](https://fetch.spec.whatwg.org/#request-class). This commit also
changes the expected web platform tests results. It also modifies the
following files:
components/net_traits/request.rs
HeapSizeOf is implemented in net_traits/request so that dom::request can
be used as a wrapper around net_traits::request::Request.
components/script/dom/headers.rs
Several methods are added to Headers so that request can access and
modify some of the headers fields.
Diffstat (limited to 'components/net_traits/request.rs')
-rw-r--r-- | components/net_traits/request.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs index bf7e22d2d0b..6b9d4618fc2 100644 --- a/components/net_traits/request.rs +++ b/components/net_traits/request.rs @@ -10,7 +10,7 @@ use std::mem::swap; use url::{Origin as UrlOrigin, Url}; /// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum Initiator { None, Download, @@ -20,14 +20,14 @@ pub enum Initiator { } /// A request [type](https://fetch.spec.whatwg.org/#concept-request-type) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum Type { None, Audio, Font, Image, Script, Style, Track, Video } /// A request [destination](https://fetch.spec.whatwg.org/#concept-request-destination) -#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)] pub enum Destination { None, Document, Embed, Font, Image, Manifest, Media, Object, Report, Script, ServiceWorker, @@ -35,14 +35,14 @@ pub enum Destination { } /// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin) -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Debug, HeapSizeOf)] pub enum Origin { Client, Origin(UrlOrigin) } /// A [referer](https://fetch.spec.whatwg.org/#concept-request-referrer) -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, HeapSizeOf)] pub enum Referer { NoReferer, /// Default referer if nothing is specified @@ -51,7 +51,7 @@ pub enum Referer { } /// A [request mode](https://fetch.spec.whatwg.org/#concept-request-mode) -#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)] pub enum RequestMode { Navigate, SameOrigin, @@ -60,7 +60,7 @@ pub enum RequestMode { } /// Request [credentials mode](https://fetch.spec.whatwg.org/#concept-request-credentials-mode) -#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)] pub enum CredentialsMode { Omit, CredentialsSameOrigin, @@ -68,7 +68,7 @@ pub enum CredentialsMode { } /// [Cache mode](https://fetch.spec.whatwg.org/#concept-request-cache-mode) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum CacheMode { Default, NoStore, @@ -79,7 +79,7 @@ pub enum CacheMode { } /// [Redirect mode](https://fetch.spec.whatwg.org/#concept-request-redirect-mode) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum RedirectMode { Follow, Error, @@ -87,7 +87,7 @@ pub enum RedirectMode { } /// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum ResponseTainting { Basic, CORSTainting, @@ -95,7 +95,7 @@ pub enum ResponseTainting { } /// [Window](https://fetch.spec.whatwg.org/#concept-request-window) -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum Window { NoWindow, Client, @@ -134,11 +134,13 @@ pub struct RequestInit { } /// A [Request](https://fetch.spec.whatwg.org/#requests) as defined by the Fetch spec -#[derive(Clone)] +#[derive(Clone, HeapSizeOf)] pub struct Request { + #[ignore_heap_size_of = "Defined in hyper"] pub method: RefCell<Method>, pub local_urls_only: bool, pub sandboxed_storage_area_urls: bool, + #[ignore_heap_size_of = "Defined in hyper"] pub headers: RefCell<Headers>, pub unsafe_request: bool, pub body: RefCell<Option<Vec<u8>>>, |