mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Add spec links to the Request fields
This commit is contained in:
parent
a55cb8425d
commit
d2dc425336
1 changed files with 29 additions and 1 deletions
|
@ -186,45 +186,69 @@ impl Default for RequestInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [Request](https://fetch.spec.whatwg.org/#requests) as defined by the Fetch spec
|
/// A [Request](https://fetch.spec.whatwg.org/#concept-request) as defined by
|
||||||
|
/// the Fetch spec.
|
||||||
#[derive(Clone, HeapSizeOf)]
|
#[derive(Clone, HeapSizeOf)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-method
|
||||||
#[ignore_heap_size_of = "Defined in hyper"]
|
#[ignore_heap_size_of = "Defined in hyper"]
|
||||||
pub method: Method,
|
pub method: Method,
|
||||||
|
/// https://fetch.spec.whatwg.org/#local-urls-only-flag
|
||||||
pub local_urls_only: bool,
|
pub local_urls_only: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#sandboxed-storage-area-urls-flag
|
||||||
pub sandboxed_storage_area_urls: bool,
|
pub sandboxed_storage_area_urls: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-header-list
|
||||||
#[ignore_heap_size_of = "Defined in hyper"]
|
#[ignore_heap_size_of = "Defined in hyper"]
|
||||||
pub headers: Headers,
|
pub headers: Headers,
|
||||||
|
/// https://fetch.spec.whatwg.org/#unsafe-request-flag
|
||||||
pub unsafe_request: bool,
|
pub unsafe_request: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-body
|
||||||
pub body: Option<Vec<u8>>,
|
pub body: Option<Vec<u8>>,
|
||||||
// TODO: client object
|
// TODO: client object
|
||||||
pub is_service_worker_global_scope: bool,
|
pub is_service_worker_global_scope: bool,
|
||||||
pub window: Window,
|
pub window: Window,
|
||||||
// TODO: target browsing context
|
// TODO: target browsing context
|
||||||
|
/// https://fetch.spec.whatwg.org/#request-keepalive-flag
|
||||||
pub keep_alive: bool,
|
pub keep_alive: bool,
|
||||||
pub skip_service_worker: bool,
|
pub skip_service_worker: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-initiator
|
||||||
pub initiator: Initiator,
|
pub initiator: Initiator,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-type
|
||||||
pub type_: Type,
|
pub type_: Type,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-destination
|
||||||
pub destination: Destination,
|
pub destination: Destination,
|
||||||
// TODO: priority object
|
// TODO: priority object
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-origin
|
||||||
pub origin: Origin,
|
pub origin: Origin,
|
||||||
pub omit_origin_header: bool,
|
pub omit_origin_header: bool,
|
||||||
/// https://fetch.spec.whatwg.org/#concept-request-referrer
|
/// https://fetch.spec.whatwg.org/#concept-request-referrer
|
||||||
pub referrer: Referrer,
|
pub referrer: Referrer,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-referrer-policy
|
||||||
pub referrer_policy: Option<ReferrerPolicy>,
|
pub referrer_policy: Option<ReferrerPolicy>,
|
||||||
pub pipeline_id: Option<PipelineId>,
|
pub pipeline_id: Option<PipelineId>,
|
||||||
|
/// https://fetch.spec.whatwg.org/#synchronous-flag
|
||||||
pub synchronous: bool,
|
pub synchronous: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-mode
|
||||||
pub mode: RequestMode,
|
pub mode: RequestMode,
|
||||||
|
/// https://fetch.spec.whatwg.org/#use-cors-preflight-flag
|
||||||
pub use_cors_preflight: bool,
|
pub use_cors_preflight: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-credentials-mode
|
||||||
pub credentials_mode: CredentialsMode,
|
pub credentials_mode: CredentialsMode,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag
|
||||||
pub use_url_credentials: bool,
|
pub use_url_credentials: bool,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-cache-mode
|
||||||
pub cache_mode: CacheMode,
|
pub cache_mode: CacheMode,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-redirect-mode
|
||||||
pub redirect_mode: RedirectMode,
|
pub redirect_mode: RedirectMode,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-integrity-metadata
|
||||||
pub integrity_metadata: String,
|
pub integrity_metadata: String,
|
||||||
// Use the last method on url_list to act as spec current url field, and
|
// Use the last method on url_list to act as spec current url field, and
|
||||||
// first method to act as spec url field
|
// first method to act as spec url field
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-url-list
|
||||||
pub url_list: Vec<ServoUrl>,
|
pub url_list: Vec<ServoUrl>,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-redirect-count
|
||||||
pub redirect_count: u32,
|
pub redirect_count: u32,
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-response-tainting
|
||||||
pub response_tainting: ResponseTainting,
|
pub response_tainting: ResponseTainting,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,18 +320,22 @@ impl Request {
|
||||||
req
|
req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-url
|
||||||
pub fn url(&self) -> ServoUrl {
|
pub fn url(&self) -> ServoUrl {
|
||||||
self.url_list.first().unwrap().clone()
|
self.url_list.first().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://fetch.spec.whatwg.org/#concept-request-current-url
|
||||||
pub fn current_url(&self) -> ServoUrl {
|
pub fn current_url(&self) -> ServoUrl {
|
||||||
self.url_list.last().unwrap().clone()
|
self.url_list.last().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://fetch.spec.whatwg.org/#navigation-request
|
||||||
pub fn is_navigation_request(&self) -> bool {
|
pub fn is_navigation_request(&self) -> bool {
|
||||||
self.destination == Destination::Document
|
self.destination == Destination::Document
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://fetch.spec.whatwg.org/#subresource-request
|
||||||
pub fn is_subresource_request(&self) -> bool {
|
pub fn is_subresource_request(&self) -> bool {
|
||||||
match self.destination {
|
match self.destination {
|
||||||
Destination::Font | Destination::Image | Destination::Manifest | Destination::Media |
|
Destination::Font | Destination::Image | Destination::Manifest | Destination::Media |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue