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

Fix #2317 force conversion to FormData for xhr.send #2481

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

Telroshan
Copy link
Collaborator

Description

In a multipart/form-data form, current implementation with the proxied FormData results in requests being malformed (wrong content type set to text/plain, FormData sent as [object FormData] in the payload)
Couldn't get the proxy object to work properly with XMLHTTPRequest's send method; even though calls are being forwarded to the underlying FormData through the proxy, the request won't set its type to multipart/form-data when appropriate and instead send a text/plain request.
One simple fix/workaround here is to copy the values into a new, actual FormData (not a proxied one)

Corresponding issue:
#2317
Also see this JSFiddle to reproduce the issue

Testing

Didn't know how to add a reliable test for this tbh, given that we mock the requests in our test suite

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

Couldn't get the proxy object to work properly with XMLHTTPRequest's send method.
Even though calls are being forwarded to its underlying FormData through the proxy, the request won't set its type to multipart/form-data when appropriate and instead send a text/plain request
@Telroshan Telroshan added the bug Something isn't working label Apr 14, 2024
@1cg 1cg merged commit 54381a2 into bigskysoftware:dev Apr 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants