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

[Bug] Android: malformed empty multipart requests #372

Closed
silviogutierrez opened this issue Oct 2, 2020 · 3 comments
Closed

[Bug] Android: malformed empty multipart requests #372

silviogutierrez opened this issue Oct 2, 2020 · 3 comments
Labels

Comments

@silviogutierrez
Copy link

Describe the bug

First of all: thanks for all your work on this library. It's a life saver with cookies and avoiding CORS.

On Android only, if you post multipart with an empty FormData object, the boundary is not set. This is invalid and some frameworks will refuses to parse the request. See here: https://stackoverflow.com/questions/34326150/multipartparsererror-invalid-boundary

Note: only happens on Android, not on iOS. I don't know much Android native dev, but I added a few breakpoints and startPart in HttpRequest.java is not called for empty requests. So the boundary is missing. See screenshots.

System info

  • affected HTTP plugin version: all versions higher than and including 2.3.1
  • affected platform(s) and version(s): Android
  • affected device(s): all

Minimum viable code to reproduce

Using ionic's wrapper:

await HTTP.sendRequest(url, {
  method: "post",
  serializer: "multipart",
  data: new FormData(),
})

Screenshots
With data:

image

Without data (bug):
image

@silkimen
Copy link
Owner

Hi Silvio, I've checked how an empty FormData instance is handled in AFNEtworking (on iOS). It's just falling back to an empty url encoded request instead, which seemed strange at first sight. But on the other hand: it never caused problems as yet and sending empty multipart requests should be an extremely rare case. So I've decided to match this behavior on Android. This issue will be fixed in 3.1.1. 🤗

@silviogutierrez
Copy link
Author

silviogutierrez commented Oct 20, 2020 via email

@zdevaty
Copy link

zdevaty commented Apr 12, 2021

Hello @silkimen, can you please tag the 3.1.1 for release?

ath0mas added a commit to ns0m/cordova-plugin-advanced-http that referenced this issue Feb 6, 2024
ath0mas added a commit to ns0m/cordova-plugin-advanced-http that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants