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. --> Source-Repo: https://github.com/servo/servo Source-Revision: 78160bf3f967ad34c671fe953de578bfa0b9542b
109 lines
2.0 KiB
Plaintext
109 lines
2.0 KiB
Plaintext
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
// https://fetch.spec.whatwg.org/#request-class
|
|
|
|
typedef (Request or USVString) RequestInfo;
|
|
|
|
[Constructor(RequestInfo input, optional RequestInit init),
|
|
Exposed=(Window,Worker)]
|
|
|
|
interface Request {
|
|
readonly attribute ByteString method;
|
|
readonly attribute USVString url;
|
|
[SameObject] readonly attribute Headers headers;
|
|
readonly attribute RequestType type;
|
|
readonly attribute RequestDestination destination;
|
|
readonly attribute USVString referrer;
|
|
readonly attribute ReferrerPolicy referrerPolicy;
|
|
readonly attribute RequestMode mode;
|
|
readonly attribute RequestCredentials credentials;
|
|
readonly attribute RequestCache cache;
|
|
readonly attribute RequestRedirect redirect;
|
|
readonly attribute DOMString integrity;
|
|
[NewObject, Throws] Request clone();
|
|
};
|
|
|
|
Request implements Body;
|
|
|
|
dictionary RequestInit {
|
|
ByteString method;
|
|
HeadersInit headers;
|
|
BodyInit? body;
|
|
USVString referrer;
|
|
ReferrerPolicy referrerPolicy;
|
|
RequestMode mode;
|
|
RequestCredentials credentials;
|
|
RequestCache cache;
|
|
RequestRedirect redirect;
|
|
DOMString integrity;
|
|
any window; // can only be set to null
|
|
};
|
|
|
|
enum RequestType {
|
|
"",
|
|
"audio",
|
|
"font",
|
|
"image",
|
|
"script",
|
|
"style",
|
|
"track",
|
|
"video"
|
|
};
|
|
|
|
enum RequestDestination {
|
|
"",
|
|
"document",
|
|
"embed",
|
|
"font",
|
|
"image",
|
|
"manifest",
|
|
"media",
|
|
"object",
|
|
"report",
|
|
"script",
|
|
"serviceworker",
|
|
"sharedworker",
|
|
"style",
|
|
"worker",
|
|
"xslt"
|
|
};
|
|
|
|
enum RequestMode {
|
|
"navigate",
|
|
"same-origin",
|
|
"no-cors",
|
|
"cors"
|
|
};
|
|
|
|
enum RequestCredentials {
|
|
"omit",
|
|
"same-origin",
|
|
"include"
|
|
};
|
|
|
|
enum RequestCache {
|
|
"default",
|
|
"no-store",
|
|
"reload",
|
|
"no-cache",
|
|
"force-cache",
|
|
"only-if-cached"
|
|
};
|
|
|
|
enum RequestRedirect {
|
|
"follow",
|
|
"error",
|
|
"manual"
|
|
};
|
|
|
|
enum ReferrerPolicy {
|
|
"",
|
|
"no-referrer",
|
|
"no-referrer-when-downgrade",
|
|
"origin",
|
|
"origin-when-cross-origin",
|
|
"unsafe-url"
|
|
};
|