New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response API #13058
Response API #13058
Conversation
Heads up! This PR modifies the following files:
|
r? @jdm |
Oops, looks like there's still some compilation errors:
https://travis-ci.org/servo/servo/jobs/155384418#L2693 etc |
Great start! Reviewed 27 of 27 files at r1. components/devtools/actors/network_event.rs, line 366 [r1] (raw file):
self.response.status = response.status.as_ref().map(|&(s, ref st)| {
let status_text = UTF_8.decode(st, DecoderTrap::Replace).unwrap();
RawStatus(s, Cow::from(status_text))
}); components/net/http_loader.rs, line 1085 [r1] (raw file):
I think we can use components/net/fetch/methods.rs, line 977 [r1] (raw file):
I think we can remove the components/script/dom/headers.rs, line 232 [r1] (raw file):
Why are we making this change? components/script/dom/htmlscriptelement.rs, line 160 [r1] (raw file):
No need for the () here. components/script/dom/request.rs, line 44 [r1] (raw file):
I don't understand why we're making this change. components/script/dom/response.rs, line 25 [r1] (raw file):
We should be able to derive HeapSizeOf on the original type and remove this. components/script/dom/response.rs, line 29 [r1] (raw file):
Why use a ByteString here? components/script/dom/response.rs, line 47 [r1] (raw file):
nit: merge this with the previous line. components/script/dom/response.rs, line 68 [r1] (raw file):
I don't think this line should be necessary. When we call components/script/dom/response.rs, line 92 [r1] (raw file):
It seems reasonable to use components/script/dom/response.rs, line 107 [r1] (raw file):
Can we use components/script/dom/response.rs, line 127 [r1] (raw file):
I believe this operation should be defined in net_traits/response.rs instead. components/script/dom/response.rs, line 134 [r1] (raw file):
This should check for whether components/script/dom/response.rs, line 179 [r1] (raw file):
let url = match parsed_url {
Ok(url) => url,
Err(_) => return Err(...),
}; components/script/dom/response.rs, line 239 [r1] (raw file):
I believe components/script/dom/response.rs, line 243 [r1] (raw file):
components/script/dom/response.rs, line 252 [r1] (raw file):
let response = self.response.borrow();
response.url_list.borrow().len() > 1 components/script/dom/response.rs, line 291 [r1] (raw file):
This should use Headers::for_response, or the guard will be wrong. components/script/dom/response.rs, line 301 [r1] (raw file):
This should probably delegate to Response::new_inherited/Response::new instead. components/script/dom/webidls/Response.webidl, line 37 [r1] (raw file):
Let's remove this comment and the commented out code, in that case. components/servo/Cargo.lock, line 490 [r1] (raw file):
We'll need to run tests/wpt/web-platform-tests/fetch/api/response/response-static-redirect.html, line 26 [r1] (raw file):
nit: let's undo the indentation change that happened here. Comments from Reviewable |
☔ The latest upstream changes (presumably #13071) made this pull request unmergeable. Please resolve the merge conflicts. |
components/servo/Cargo.lock, line 490 [r1] (raw file):
|
components/script/dom/response.rs, line 243 [r1] (raw file):
|
b06aa4e
to
dd0b5b3
Compare
components/servo/Cargo.lock, line 490 [r1] (raw file):
|
r? @Manishearth |
@bors-servo try |
Response API <!-- Please describe your changes on the following line: --> This PR adds the [dom::Response](https://fetch.spec.whatwg.org/#response-class) implementation and addresses #11896. The relevant passing tests` expectations have been updated. In order to allow non-UTF-8-encoded status messages, `net_traits::response::Response`'s `raw_status` field has been changed from type [`Option<RawStatus>`](https://doc.servo.org/hyper/http/struct.RawStatus.html) to type `Option<(u16, Vec<u8>)>`. As a result, a few other files which rely on the `raw_status` field were affected and updated. TODOs: - The `body` and `trailer` methods. Relies on implementation of `ReadableStream` and `Promise`s. - Similarly, replace the dummy constructor `_body: Option<USVString>` argument with `body: ResponseBodyInit`. - Currently, whenever `r's response's header list` or `r's Headers object` are mentioned, I always modify the `headers_reflector` field (of type dom::Headers, or `r's Headers object`) and not the corresponding hyper::Headers list in the net_traits::Response field. A completely accurate interpretation of the spec might consider making both of these lists the same thing via a reference. [Discussion](whatwg/fetch#358) was [had](#12884). --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13058) <!-- Reviewable:end -->
💔 Test failed - linux-dev |
You'll need to apply this diff:
let's see what wpt says: http://build.servo.org/builders/mac-rel-wpt/builds/2899 |
@@ -38,7 +37,7 @@ pub fn factory(mut load_data: LoadData, | |||
Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![])))), | |||
charset: Some("utf-8".to_owned()), | |||
headers: None, | |||
status: Some(Serde(RawStatus(200, "OK".into()))), | |||
status: Some((200, "OK".as_bytes().to_vec())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b"OK".to_vec()
will work
|
⚡ Previous build results for arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, windows-dev are reusable. Rebuilding only mac-rel-wpt... |
@bors-servo r- force (testing) |
@bors-servo: r=Manishearth,jdm |
📌 Commit faf32a7 has been approved by |
Response API <!-- Please describe your changes on the following line: --> This PR adds the [dom::Response](https://fetch.spec.whatwg.org/#response-class) implementation and addresses #11896. The relevant passing tests` expectations have been updated. In order to allow non-UTF-8-encoded status messages, `net_traits::response::Response`'s `raw_status` field has been changed from type [`Option<RawStatus>`](https://doc.servo.org/hyper/http/struct.RawStatus.html) to type `Option<(u16, Vec<u8>)>`. As a result, a few other files which rely on the `raw_status` field were affected and updated. TODOs: - The `body` and `trailer` methods. Relies on implementation of `ReadableStream` and `Promise`s. - Similarly, replace the dummy constructor `_body: Option<USVString>` argument with `body: ResponseBodyInit`. - Currently, whenever `r's response's header list` or `r's Headers object` are mentioned, I always modify the `headers_reflector` field (of type dom::Headers, or `r's Headers object`) and not the corresponding hyper::Headers list in the net_traits::Response field. A completely accurate interpretation of the spec might consider making both of these lists the same thing via a reference. [Discussion](whatwg/fetch#358) was [had](#12884). --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13058) <!-- Reviewable:end -->
💔 Test failed - mac-rel-wpt |
|
Response API <!-- Please describe your changes on the following line: --> This PR adds the [dom::Response](https://fetch.spec.whatwg.org/#response-class) implementation and addresses #11896. The relevant passing tests` expectations have been updated. In order to allow non-UTF-8-encoded status messages, `net_traits::response::Response`'s `raw_status` field has been changed from type [`Option<RawStatus>`](https://doc.servo.org/hyper/http/struct.RawStatus.html) to type `Option<(u16, Vec<u8>)>`. As a result, a few other files which rely on the `raw_status` field were affected and updated. TODOs: - The `body` and `trailer` methods. Relies on implementation of `ReadableStream` and `Promise`s. - Similarly, replace the dummy constructor `_body: Option<USVString>` argument with `body: ResponseBodyInit`. - Currently, whenever `r's response's header list` or `r's Headers object` are mentioned, I always modify the `headers_reflector` field (of type dom::Headers, or `r's Headers object`) and not the corresponding hyper::Headers list in the net_traits::Response field. A completely accurate interpretation of the spec might consider making both of these lists the same thing via a reference. [Discussion](whatwg/fetch#358) was [had](#12884). --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13058) <!-- Reviewable:end -->
💔 Test failed - linux-rel |
|
⚡ Previous build results for arm32, arm64, linux-dev, mac-dev-unit, mac-rel-css, windows-dev are reusable. Rebuilding only linux-rel, mac-rel-wpt... |
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
This PR adds the dom::Response implementation and addresses #11896.
The relevant passing tests` expectations have been updated.
In order to allow non-UTF-8-encoded status messages,
net_traits::response::Response
'sraw_status
field has been changed from typeOption<RawStatus>
to typeOption<(u16, Vec<u8>)>
. As a result, a few other files which rely on theraw_status
field were affected and updated.TODOs:
body
andtrailer
methods. Relies on implementation ofReadableStream
andPromise
s._body: Option<USVString>
argument withbody: ResponseBodyInit
.r's response's header list
orr's Headers object
are mentioned, I always modify theheaders_reflector
field (of type dom::Headers, orr's Headers object
) and not the corresponding hyper::Headers list in the net_traits::Response field. A completely accurate interpretation of the spec might consider making both of these lists the same thing via a reference. Discussion was had../mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is