Add spec links to the Request fields

This commit is contained in:
Anthony Ramine 2017-04-04 21:25:45 +02:00
parent a55cb8425d
commit d2dc425336

View file

@ -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)]
pub struct Request {
/// https://fetch.spec.whatwg.org/#concept-request-method
#[ignore_heap_size_of = "Defined in hyper"]
pub method: Method,
/// https://fetch.spec.whatwg.org/#local-urls-only-flag
pub local_urls_only: bool,
/// https://fetch.spec.whatwg.org/#sandboxed-storage-area-urls-flag
pub sandboxed_storage_area_urls: bool,
/// https://fetch.spec.whatwg.org/#concept-request-header-list
#[ignore_heap_size_of = "Defined in hyper"]
pub headers: Headers,
/// https://fetch.spec.whatwg.org/#unsafe-request-flag
pub unsafe_request: bool,
/// https://fetch.spec.whatwg.org/#concept-request-body
pub body: Option<Vec<u8>>,
// TODO: client object
pub is_service_worker_global_scope: bool,
pub window: Window,
// TODO: target browsing context
/// https://fetch.spec.whatwg.org/#request-keepalive-flag
pub keep_alive: bool,
pub skip_service_worker: bool,
/// 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
/// https://fetch.spec.whatwg.org/#concept-request-origin
pub origin: Origin,
pub omit_origin_header: bool,
/// https://fetch.spec.whatwg.org/#concept-request-referrer
pub referrer: Referrer,
/// https://fetch.spec.whatwg.org/#concept-request-referrer-policy
pub referrer_policy: Option<ReferrerPolicy>,
pub pipeline_id: Option<PipelineId>,
/// https://fetch.spec.whatwg.org/#synchronous-flag
pub synchronous: bool,
/// https://fetch.spec.whatwg.org/#concept-request-mode
pub mode: RequestMode,
/// https://fetch.spec.whatwg.org/#use-cors-preflight-flag
pub use_cors_preflight: bool,
/// https://fetch.spec.whatwg.org/#concept-request-credentials-mode
pub credentials_mode: CredentialsMode,
/// https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag
pub use_url_credentials: bool,
/// https://fetch.spec.whatwg.org/#concept-request-cache-mode
pub cache_mode: CacheMode,
/// https://fetch.spec.whatwg.org/#concept-request-redirect-mode
pub redirect_mode: RedirectMode,
/// https://fetch.spec.whatwg.org/#concept-request-integrity-metadata
pub integrity_metadata: String,
// Use the last method on url_list to act as spec current url field, and
// first method to act as spec url field
/// https://fetch.spec.whatwg.org/#concept-request-url-list
pub url_list: Vec<ServoUrl>,
/// https://fetch.spec.whatwg.org/#concept-request-redirect-count
pub redirect_count: u32,
/// https://fetch.spec.whatwg.org/#concept-request-response-tainting
pub response_tainting: ResponseTainting,
}
@ -296,18 +320,22 @@ impl Request {
req
}
/// https://fetch.spec.whatwg.org/#concept-request-url
pub fn url(&self) -> ServoUrl {
self.url_list.first().unwrap().clone()
}
/// https://fetch.spec.whatwg.org/#concept-request-current-url
pub fn current_url(&self) -> ServoUrl {
self.url_list.last().unwrap().clone()
}
/// https://fetch.spec.whatwg.org/#navigation-request
pub fn is_navigation_request(&self) -> bool {
self.destination == Destination::Document
}
/// 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 |