-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
Add support for FormData
request body
#1835
Add support for FormData
request body
#1835
Conversation
Ah, I forgot to mention that while tests are passing, I have issues with XO. But they not seem to be related to this PR. |
Thanks for the draft! Looking forward to this ^_^
It should be sent no matter the content type.
You read my mind :) Basically read the payload on the server and check if it's valid.
👍
I agree. /cc @sindresorhus |
👍 This will also need documentation updates. |
So I should keep header set by developer and not override it. Right?
👍
Should I include form-data deprecation in this PR? If so, how should I mention this? With
Will do! |
Correct. Only set
👍 (and)
To be honest, I'm not sure. I'm leaving this up to @sindresorhus |
…ontent-type header provided by form-data-encoder only if this header is not set by a developer. Mention spec-compliant FormData implementations in documentation.
Hmm. Do you guys have a body parser to handle FomrData bodies in your test server? |
Co-authored-by: Szymon Marczak <[email protected]>
We don't. Feel free to include one. |
About I was ended up trying to make a bare minimal parser, but realised that I basically re-implement my solution... Sooo I just added it for tests. It seem to work as expected. |
I think I gonna mark this PR as ready for a review and wait for your feedback, because I do not have any more significant changes for this feature. |
Co-authored-by: Sindre Sorhus <[email protected]>
FormData
request body
I think this tests failing is not related to the PR... |
Big thank you @octet-stream ❤️ |
It was a pleasure :) |
Is possible now use Got with multipart/formdata? |
This PR brings general support for
multipart/form-data
encoding and allows to use any spec-comliant FormData object as request body. This PR also introduces a new dependencyform-data-encoder
, so you might expect it to add about 37 KB of extra size into the install size of got.Before it's done I would like to get a feedback on few more things:
content-type
header? The encoder will generate this header and use internally to produce body content and if user will override this header - body will not be send as of now. Should I create and use the encoder in request body anyway?encoder.encode()
method returnsAsyncIterableIterator
so it basically reuse the logic for async iterator body consuming.I will keep this PR as WIP until my questions is resolved.
Further suggestions: As I said before, the good old
form-data
package is not spec-compliant and I think it should be deprecated. At least node-fetch will do so in near future (see refs section of this PR for more information).Refs:
Checklist