mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Auto merge of #12700 - jeenalee:jeena-requestAPI, r=jdm
Implement the Request API <!-- Please describe your changes on the following line: --> This PR implements the [Request API](https://fetch.spec.whatwg.org/#request-class) for the Fetch API, including its attributes and constructor, and introduces changes in relevant files. This Request integrates `net_traits::request::Request` and `dom::headers`. There are few related TODOs and comments: 1. `net_traits::request::Request`'s `headers` field does not point to `dom::request::Request`'s `headers_reflector`. 2. Every Constructor step that involves `Readable Stream` object is not implemented. 3. Every Constructor step that involves `entry settings object` or `environment settings object` is not implemented. 4. `./mach build -d` does not report any error, but prints a few warnings about unused variables related to (1) and (2). 5. Enum `ReferrerPolicy` generated by `RequestBinding` does not match `net_traits::request::Request`'s implementation. 6. `Promise`s in Body webidl are commented out. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11895 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because tests for the Request API already exists, but this commit does not implement the interface fully. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12700) <!-- Reviewable:end -->
This commit is contained in:
commit
78160bf3f9
18 changed files with 1082 additions and 399 deletions
|
@ -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,
|
||||
|
@ -138,11 +138,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>>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue