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
feat: Implement form-data encoding #603
feat: Implement form-data encoding #603
Conversation
Just some input/feedback If we should support any kind of formdata we should begin to implement our own way iterating over all key/values and generate the boundary/body ourself so we can support any custom formdata implementation. But I was considering making my FormData implementation able to run on node too (it's all synchronous). But it uses Blob so much that it's impractical to implement in Node. However i think that
Also i can see that formdata-node breaks some test that my browser polyfilled version handles correctly. I'm also a bit concerned about the constructor to, maybe in the feature FormData constructor will accept simular things like the URLSearchParams but it can also include files I get that they some methods are necessary like some async methods, getting the size. but i think they should be wrapped in a Blob/File like object. that has the size and filename information along with it Now how would you read the blob without a FileReader you may ask? well, the w3c/FileAPI are implementing new methods to the Blob prototype, namely That will be the key features to how we would know how to read the hole content of a custom FormData implementation including files. (files that have not been read into the memory) So a good formdata implementation would
for other stream you would have to create a File like object with a given size too |
Also can't help but thinking that you have been a bit influenced by my version cuz they looks a bit similar :) |
No, I'm pretty sure I haven't been influenced by your implementation. Originally
Can you tell me bore of these cases? Maybe I missed something.
That's may be a good point, but it means that another HTTP clients might have to implement that too if they want to support FormData implementations same way. I guess. And I don't think is that having those additional methods is something bad, since they're here only to take alternative way to read the data from FormData instance. Like |
Thx for the PR, this is definitely something we should look into on 3.x pre-release. Being modular and allow third-party to provide API implementation is one of our goal. (To be honest I am a quite busy with my C# project, if @jimmywarting @octet-stream you would like to merge this and help move forward 3.x pre-release, I am happy to help) |
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@octet-stream any idea why Windows test is failing? |
Not really. But this happens in main.js tests only, which means the rest of encoding implementation works fine on windows and the problem is not in formdata-node as well. Maybe the problem appears somewhere in node-fetch integration with form-data or it is the test server problem, or maybe something else. |
…stream/form-data-support
@octet-stream it was an outdated dependency problem. Replacing Breaking tests are irrelevant to this PR (is due to fetch-blob upgrade, see #870 ) |
BONUS: we don't skip any tests on Windows anymore |
@xxczaki This is ready to merge 🎉 |
This pull request brings support of the spec-compliant FormData in request body.
As an example I'm using formdata-node package (for tests and docs).
Notes on the PR:
FormData#getComputedLength()