diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2017-10-21 06:39:23 -0700 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2017-10-23 11:19:35 -0700 |
commit | c6bb1cb9d553c13a20dace3e32b9643c433caa1e (patch) | |
tree | 0d0e46e00362136c6c7d62dc76accce9d37e27cc /components/net_traits/request.rs | |
parent | 48c715c1c86301d0f25e70d3e690d04d8303c58f (diff) | |
download | servo-c6bb1cb9d553c13a20dace3e32b9643c433caa1e.tar.gz servo-c6bb1cb9d553c13a20dace3e32b9643c433caa1e.zip |
Merge request type and destination
Diffstat (limited to 'components/net_traits/request.rs')
-rw-r--r-- | components/net_traits/request.rs | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs index 409ff756daa..3fcaa72f585 100644 --- a/components/net_traits/request.rs +++ b/components/net_traits/request.rs @@ -19,37 +19,37 @@ pub enum Initiator { XSLT, } -/// A request [type](https://fetch.spec.whatwg.org/#concept-request-type) -#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] -pub enum Type { - None, - Audio, - Font, - Image, - Script, - Style, - Track, - Video, -} - /// A request [destination](https://fetch.spec.whatwg.org/#concept-request-destination) #[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Destination { None, + Audio, Document, Embed, Font, Image, Manifest, - Media, Object, Report, Script, ServiceWorker, SharedWorker, Style, + Track, + Video, Worker, - XSLT, + Xslt, +} + +impl Destination { + /// https://fetch.spec.whatwg.org/#request-destination-script-like + #[inline] + pub fn is_script_like(&self) -> bool { + *self == Destination::Script || + *self == Destination::ServiceWorker || + *self == Destination::SharedWorker || + *self == Destination::Worker + } } /// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin) @@ -150,7 +150,6 @@ pub struct RequestInit { pub body: Option<Vec<u8>>, pub service_workers_mode: ServiceWorkersMode, // TODO: client object - pub type_: Type, pub destination: Destination, pub synchronous: bool, pub mode: RequestMode, @@ -178,7 +177,6 @@ impl Default for RequestInit { unsafe_request: false, body: None, service_workers_mode: ServiceWorkersMode::All, - type_: Type::None, destination: Destination::None, synchronous: false, mode: RequestMode::NoCors, @@ -224,8 +222,6 @@ pub struct Request { pub service_workers_mode: ServiceWorkersMode, /// <https://fetch.spec.whatwg.org/#concept-request-initiator> pub initiator: Initiator, - /// <https://fetch.spec.whatwg.org/#concept-request-type> - pub type_: Type, /// <https://fetch.spec.whatwg.org/#concept-request-destination> pub destination: Destination, // TODO: priority object @@ -278,7 +274,6 @@ impl Request { keep_alive: false, service_workers_mode: ServiceWorkersMode::All, initiator: Initiator::None, - type_: Type::None, destination: Destination::None, origin: origin.unwrap_or(Origin::Client), referrer: Referrer::Client, @@ -307,7 +302,6 @@ impl Request { req.unsafe_request = init.unsafe_request; req.body = init.body; req.service_workers_mode = init.service_workers_mode; - req.type_ = init.type_; req.destination = init.destination; req.synchronous = init.synchronous; req.mode = init.mode; @@ -356,8 +350,9 @@ impl Request { /// <https://fetch.spec.whatwg.org/#subresource-request> pub fn is_subresource_request(&self) -> bool { match self.destination { - Destination::Font | Destination::Image | Destination::Manifest | Destination::Media | - Destination::Script | Destination::Style | Destination::XSLT | Destination::None => true, + Destination::Audio | Destination::Font | Destination::Image | Destination::Manifest | + Destination::Script | Destination::Style | Destination::Track | Destination::Video | + Destination::Xslt | Destination::None => true, _ => false, } } |