-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feature Request: support body from ReadableStream #55
Comments
Hi @cdaringe This sounds indeed like a useful addition, however I'd like to keep the fetchToCurl function synchronous for now. And I assume that implementing this would require it to be async right? However if we hide this feature behind a flag or configuration option it shouldn't break any code which relies on it returning the string immediately. Are you interested in opening a PR? Best regards |
Yes to all! |
So I started working on it, and i hit a few snags. I ended up wanting
...that I just forked. https://github.com/cdaringe/fetch-to-curl-ts With that said, i'm happy to close the fork iff you're interested in the totality of the changes! I just kinda got to hackin... and I either was gonna send you a massive PR, a wave a PRs, or this fork, and all were kinda overwhelming feeling (but i wanted stuff now)! Sorry for the noise. Lemme know what you think. -CD |
I've not forgotten about this and will check it out :) |
Problem
fetchToCurl(new Request(myUrl, { method: 'POST', body: someReadableStream })
doesn't work, and yields--data-binary={}
Discussion
It's easy to get into wanting this case when dealing with Request instances from common node tools. For example, I'm using
msw
, which... by the time a request is exiting the VM and you're in a proxy handler, body is converted to a stream just from node itself.Here's a dummy example of what we could do:
Then, rather than a naive
if (typeof body === 'object') { ... }
, we could first do aif (typeof req.body?.getReader === 'function) { ... }
and do the needfulThe text was updated successfully, but these errors were encountered: