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 upImplement Blob response for XMLHttpRequest: #9623 #9629
Conversation
| @@ -726,6 +729,32 @@ impl XMLHttpRequestMethods for XMLHttpRequest { | |||
| return NullValue(); | |||
| } | |||
| } | |||
| XMLHttpRequestResponseType::Blob => { | |||
| match self.response_blob.get() { | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
This should really go into a separate method down there, named blob_response, with an annotation containing the corresponding link to the WHATWG specification.
|
Review status: 0 of 2 files reviewed at latest revision, 3 unresolved discussions. components/script/dom/xmlhttprequest.rs, line 126 [r1] (raw file): components/script/dom/xmlhttprequest.rs, line 757 [r1] (raw file): Comments from the review on Reviewable.io |
| @@ -1,5 +1,5 @@ | |||
| [response-data-blob.htm] | |||
| type: testharness | |||
| [XMLHttpRequest: The response attribute: Blob data] | |||
| expected: FAIL | |||
| expected: PASS | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
This is not how we change test expectations. If it is expected to PASS, you can just delete the line. In fact, since there's only one expected test failure in this .ini file, you can delete the entire file.
|
Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions. components/script/dom/xmlhttprequest.rs, line 733 [r1] (raw file): Comments from the review on Reviewable.io |
|
Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions. tests/wpt/metadata/XMLHttpRequest/response-data-blob.htm.ini, line 4 [r1] (raw file): Comments from the review on Reviewable.io |
| @@ -1038,6 +1052,25 @@ impl XMLHttpRequest { | |||
| encoding.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap().to_owned() | |||
| } | |||
|
|
|||
| fn blob_response(&self) -> Root<Blob> { | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
Spec link above this function, please. (https://xhr.spec.whatwg.org/#blob-response)
| } | ||
| }, | ||
| XMLHttpRequestResponseType::Blob => { | ||
| // Step 1 |
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
This step should also be moved to blob_response. All we should have here is a single call to blob_response.
| fn blob_response(&self) -> Root<Blob> { | ||
| // Step 1 | ||
| match self.response_blob.get() { | ||
| Some(response) => response, |
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
We could simplify this step as if let Some(blob) = self.response_blob.get() { return blob; }
| Some(response) => response, | ||
| None => { | ||
| // Step 2 | ||
| let mime: String = match self.response_headers.borrow().get() { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
There is a final_mime_type() function defined, so this isn't necessary.
|
|
||
| // Step 4 | ||
| let blob = Blob::new(self.global().r(), body, &mime); | ||
| self.response_blob.set(Some(blob.r())); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| // Step 3 | ||
| let bytes = self.response.borrow(); | ||
| let body = if bytes.is_empty() { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
This step here doesn't seem necessary. I think let blob = Blob::new(self.global().r(), self.response.borrow().to_vec(), &mime); down there would be sufficient.
|
Review status: 0 of 2 files reviewed at latest revision, 10 unresolved discussions. components/script/dom/xmlhttprequest.rs, line 1054 [r3] (raw file): components/script/dom/xmlhttprequest.rs, line 1061 [r3] (raw file): Comments from the review on Reviewable.io |
| return response; | ||
| } | ||
| // Step 2 | ||
| let mime = match self.final_mime_type() { |
This comment has been minimized.
This comment has been minimized.
|
Almost there! r=me with that final nit. |
| return response; | ||
| } | ||
| // Step 2 | ||
| let mime = self.final_mime_type().map(|x| x.to_string()).unwrap_or("".to_owned()); |
This comment has been minimized.
This comment has been minimized.
KiChjang
Feb 14, 2016
Member
use std::string::ToString
and then .as_ref().map(ToString::to_string) should work.
|
Ah, brainfarted. Everything looks fine right now, thanks for working on this! @bors-servo r+ |
|
|
Implement Blob response for XMLHttpRequest: #9623 My first attempt at implementing the Blob response for XMLHttpRequest. The expected result for the response `tests/wpt/web-platform-test/HMLHttpRequest/response-blob-data.htm` is also changed to `PASS`. Please let me know if you see any areas in which I can improve this PR! Fixes #9623 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9629) <!-- Reviewable:end -->
|
|
|
|
Implement Blob response for XMLHttpRequest: #9623 My first attempt at implementing the Blob response for XMLHttpRequest. The expected result for the response `tests/wpt/web-platform-test/HMLHttpRequest/response-blob-data.htm` is also changed to `PASS`. Please let me know if you see any areas in which I can improve this PR! Fixes #9623 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9629) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
Implement Blob response for XMLHttpRequest: #9623 My first attempt at implementing the Blob response for XMLHttpRequest. The expected result for the response `tests/wpt/web-platform-test/HMLHttpRequest/response-blob-data.htm` is also changed to `PASS`. Please let me know if you see any areas in which I can improve this PR! Fixes #9623 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9629) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
Implement Blob response for XMLHttpRequest: #9623 My first attempt at implementing the Blob response for XMLHttpRequest. The expected result for the response `tests/wpt/web-platform-test/HMLHttpRequest/response-blob-data.htm` is also changed to `PASS`. Please let me know if you see any areas in which I can improve this PR! Fixes #9623 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9629) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
|
|
dlrobertson commentedFeb 14, 2016
My first attempt at implementing the Blob response for XMLHttpRequest. The expected result for the response
tests/wpt/web-platform-test/HMLHttpRequest/response-blob-data.htmis also changed toPASS. Please let me know if you see any areas in which I can improve this PR!Fixes #9623