Skip to content
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

Implement typed array support for XMLHttpRequest's send API #20343

Closed
jdm opened this issue Mar 19, 2018 · 5 comments
Closed

Implement typed array support for XMLHttpRequest's send API #20343

jdm opened this issue Mar 19, 2018 · 5 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Mar 19, 2018

Now that #20267 has merged, we can uncomment the BufferSource argument to allow XMLHttpRequest.send() to support sending typed arrays as the XHR body. This will require extracting the data from the typed array in this code.

Code: components/script/dom/webidls/XMLHttpRequest.webidl, components/script/dom/xmlhttprequest.rs
Tests: ./mach test-wpt tests/wpt/web-platform-tests/xhr/ (this should generate a bunch of new test pass results)

@nupurbaghel
Copy link
Contributor

@nupurbaghel nupurbaghel commented Mar 23, 2018

This appears to be an interesting issue. I would surely like to work on it 😄

@jdm jdm added the C-assigned label Mar 23, 2018
@nupurbaghel
Copy link
Contributor

@nupurbaghel nupurbaghel commented Mar 24, 2018

The BodyInit requires extracting both the data and content_type. For a typed array, I was trying to get data using to_vec() method which requires some dereferencing I think, but I was wondering how the content type should be defined here. Should we give it a value None if its absent and Int32 otherwise ?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 24, 2018

https://fetch.spec.whatwg.org/#concept-bodyinit-extract does not assign a value for content_type when the input is an arraybuffer, so leaving a None value is appropriate.

@nupurbaghel
Copy link
Contributor

@nupurbaghel nupurbaghel commented Mar 25, 2018

I tried using the following code to extract data

Some(DocumentOrBodyInit::ArrayBuffer(ref typedarray)) => Some((typedarray.to_vec(), None))

This results in an error: cannot borrow immutable borrowed content *typedarray as mutable.
I couldn't find a better match than the to_vec() method which requires a mutable reference of data. data() method of typed array was one other option but that is a private method.
I need some help on how to proceed 😅
Thank you so much :)

@jdm
Copy link
Member Author

@jdm jdm commented Mar 25, 2018

If you rebase against Servo master, that problem should be gone (it was fixed by servo/rust-mozjs#408).

bors-servo added a commit that referenced this issue Mar 26, 2018
Typed array support for XMLHttpRequest's send API

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #20343

<!-- Either: -->
- [x] Updated some tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/20434)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Mar 26, 2018
Typed array support for XMLHttpRequest's send API

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #20343

<!-- Either: -->
- [x] Updated some tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/20434)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Mar 28, 2018
Typed array support for XMLHttpRequest's send API

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #20343

<!-- Either: -->
- [x] Updated some tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/20434)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Mar 29, 2018
Typed array support for XMLHttpRequest's send API

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #20343

<!-- Either: -->
- [x] Updated some tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/20434)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.