mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rustfmt net_traits.
This commit is contained in:
parent
b76613a389
commit
b46846e2a0
9 changed files with 151 additions and 120 deletions
|
@ -9,7 +9,7 @@ use msg::constellation_msg::PipelineId;
|
|||
use servo_url::ServoUrl;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::default::Default;
|
||||
use url::{Origin as UrlOrigin};
|
||||
use url::Origin as UrlOrigin;
|
||||
|
||||
/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
|
||||
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
|
@ -18,29 +18,47 @@ pub enum Initiator {
|
|||
Download,
|
||||
ImageSet,
|
||||
Manifest,
|
||||
XSLT
|
||||
XSLT,
|
||||
}
|
||||
|
||||
/// A request [type](https://fetch.spec.whatwg.org/#concept-request-type)
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)]
|
||||
pub enum Type {
|
||||
None, Audio, Font, Image,
|
||||
Script, Style, Track, Video
|
||||
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, HeapSizeOf)]
|
||||
pub enum Destination {
|
||||
None, Document, Embed, Font, Image, Manifest,
|
||||
Media, Object, Report, Script, ServiceWorker,
|
||||
SharedWorker, Style, Worker, XSLT
|
||||
None,
|
||||
Document,
|
||||
Embed,
|
||||
Font,
|
||||
Image,
|
||||
Manifest,
|
||||
Media,
|
||||
Object,
|
||||
Report,
|
||||
Script,
|
||||
ServiceWorker,
|
||||
SharedWorker,
|
||||
Style,
|
||||
Worker,
|
||||
XSLT,
|
||||
}
|
||||
|
||||
/// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin)
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
pub enum Origin {
|
||||
Client,
|
||||
Origin(UrlOrigin)
|
||||
Origin(UrlOrigin),
|
||||
}
|
||||
|
||||
/// A [referer](https://fetch.spec.whatwg.org/#concept-request-referrer)
|
||||
|
@ -49,7 +67,7 @@ pub enum Referrer {
|
|||
NoReferrer,
|
||||
/// Default referrer if nothing is specified
|
||||
Client,
|
||||
ReferrerUrl(ServoUrl)
|
||||
ReferrerUrl(ServoUrl),
|
||||
}
|
||||
|
||||
/// A [request mode](https://fetch.spec.whatwg.org/#concept-request-mode)
|
||||
|
@ -58,7 +76,7 @@ pub enum RequestMode {
|
|||
Navigate,
|
||||
SameOrigin,
|
||||
NoCors,
|
||||
CorsMode
|
||||
CorsMode,
|
||||
}
|
||||
|
||||
/// Request [credentials mode](https://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
||||
|
@ -66,7 +84,7 @@ pub enum RequestMode {
|
|||
pub enum CredentialsMode {
|
||||
Omit,
|
||||
CredentialsSameOrigin,
|
||||
Include
|
||||
Include,
|
||||
}
|
||||
|
||||
/// [Cache mode](https://fetch.spec.whatwg.org/#concept-request-cache-mode)
|
||||
|
@ -77,7 +95,7 @@ pub enum CacheMode {
|
|||
Reload,
|
||||
NoCache,
|
||||
ForceCache,
|
||||
OnlyIfCached
|
||||
OnlyIfCached,
|
||||
}
|
||||
|
||||
/// [Redirect mode](https://fetch.spec.whatwg.org/#concept-request-redirect-mode)
|
||||
|
@ -85,7 +103,7 @@ pub enum CacheMode {
|
|||
pub enum RedirectMode {
|
||||
Follow,
|
||||
Error,
|
||||
Manual
|
||||
Manual,
|
||||
}
|
||||
|
||||
/// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
||||
|
@ -93,22 +111,21 @@ pub enum RedirectMode {
|
|||
pub enum ResponseTainting {
|
||||
Basic,
|
||||
CorsTainting,
|
||||
Opaque
|
||||
Opaque,
|
||||
}
|
||||
|
||||
/// [Window](https://fetch.spec.whatwg.org/#concept-request-window)
|
||||
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
pub enum Window {
|
||||
NoWindow,
|
||||
Client,
|
||||
// TODO: Environmental settings object
|
||||
Client, // TODO: Environmental settings object
|
||||
}
|
||||
|
||||
/// [CORS settings attribute](https://html.spec.whatwg.org/multipage/#attr-crossorigin-anonymous)
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum CorsSettings {
|
||||
Anonymous,
|
||||
UseCredentials
|
||||
UseCredentials,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, HeapSizeOf)]
|
||||
|
@ -214,7 +231,8 @@ impl Request {
|
|||
pub fn new(url: ServoUrl,
|
||||
origin: Option<Origin>,
|
||||
is_service_worker_global_scope: bool,
|
||||
pipeline_id: Option<PipelineId>) -> Request {
|
||||
pipeline_id: Option<PipelineId>)
|
||||
-> Request {
|
||||
Request {
|
||||
method: RefCell::new(Method::Get),
|
||||
local_urls_only: false,
|
||||
|
@ -251,7 +269,8 @@ impl Request {
|
|||
pub fn from_init(init: RequestInit) -> Request {
|
||||
let mut req = Request::new(init.url,
|
||||
Some(Origin::Origin(init.origin.origin())),
|
||||
false, init.pipeline_id);
|
||||
false,
|
||||
init.pipeline_id);
|
||||
*req.method.borrow_mut() = init.method;
|
||||
*req.headers.borrow_mut() = init.headers;
|
||||
req.unsafe_request = init.unsafe_request;
|
||||
|
@ -289,11 +308,9 @@ impl 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,
|
||||
_ => false
|
||||
Destination::Font | Destination::Image | Destination::Manifest | Destination::Media |
|
||||
Destination::Script | Destination::Style | Destination::XSLT | Destination::None => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +319,7 @@ impl Referrer {
|
|||
pub fn to_url(&self) -> Option<&ServoUrl> {
|
||||
match *self {
|
||||
Referrer::NoReferrer | Referrer::Client => None,
|
||||
Referrer::ReferrerUrl(ref url) => Some(url)
|
||||
Referrer::ReferrerUrl(ref url) => Some(url),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue