Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upResponse API #13058
Response API #13058
Conversation
highfive
commented
Aug 26, 2016
|
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() > 1components/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 |
|
|
|
components/servo/Cargo.lock, line 490 [r1] (raw file):
|
|
components/script/dom/response.rs, line 243 [r1] (raw file):
|
|
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 -->
|
|
|
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())), | |||
This comment has been minimized.
This comment has been minimized.
| redirectResponse = Response.redirect(url, status); | ||
| assert_equals(redirectResponse.status, status, "Redictect status is " + status); | ||
| redirectResponse = Response.redirect(url, status); | ||
| assert_equals(redirectResponse.status, status, "Redirect status is " + status); |
This comment has been minimized.
This comment has been minimized.
highfive
commented
Sep 8, 2016
|
|
@bors-servo retry |
|
|
|
@bors-servo r- force (testing) |
|
@bors-servo: r=Manishearth,jdm |
|
|
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 -->
|
|
highfive
commented
Sep 8, 2016
|
|
@bors-servo: retry |
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 -->
|
|
highfive
commented
Sep 9, 2016
|
|
@bors-servo retry |
|
|
|
|
malisas commentedAug 26, 2016
•
edited by larsbergstrom
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_statusfield has been changed from typeOption<RawStatus>to typeOption<(u16, Vec<u8>)>. As a result, a few other files which rely on theraw_statusfield were affected and updated.TODOs:
bodyandtrailermethods. Relies on implementation ofReadableStreamandPromises._body: Option<USVString>argument withbody: ResponseBodyInit.r's response's header listorr's Headers objectare mentioned, I always modify theheaders_reflectorfield (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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is