-
Notifications
You must be signed in to change notification settings - Fork 541
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: add support for request iterator body #848
Conversation
Codecov Report
@@ Coverage Diff @@
## main #848 +/- ##
==========================================
- Coverage 99.90% 99.71% -0.19%
==========================================
Files 26 26
Lines 2050 2129 +79
==========================================
+ Hits 2048 2123 +75
- Misses 2 6 +4
Continue to review full report at Codecov.
|
@mcollina Does it make sense to call |
Should the |
After looking at this a bit more, I'm not 100% sure that it's needed. As Undici gets an async-iterable, the iterable supposedly should only create the resources when iteration begins (i.e. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep the existing stream code and make a separate path for iterables?
|
34b8f9d
to
a3ec5f8
Compare
I think that I've essentially done what's needed with the implementation. There are some open outstanding issues that I opened that I wasn't sure how to solve, if they're correct or if they're needed (e.g. redirect), and I tried finding and porting all of the PTAL and tell me if there are any outstanding issues, if something I did was way off in general, or if I should add benchmarks etc. |
8b168cd
to
422c9e1
Compare
@Linkgoron I helped out a little |
dbfa839
to
8486390
Compare
@@ -1587,6 +1587,8 @@ async function writeIterable ({ client, request, socket, contentLength, header, | |||
|
|||
let bytesWritten = 0 | |||
try { | |||
// TODO (fix): What if socket errors while waiting for body? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, once the next yield happens, the for...await of
will take care of it (as it throws socket[kError])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but body could be doing a lot of work before the next yield happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing something smarter, but calling return
doesn't affect the iterator at all until it yields anyway, so it somehow has to be in userland.
015814e
to
7731088
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* feature: add support for request iterator body * fix no-strict-content-length * port createReadStream tests * port client-errors tests, create async-iterator test utils * create more async utils * fix pipelining * add timeout, tls, get-head-body tests * add content-length tests * add http-req-destroy tests * remove console.log * break up for await...of * return for await...of * update docs * emulate pump * add drain listener * fixup * fixup * fixup * fixup * fixuP * fixup * fixup * avoid extra loop if drain was actually close * add bad input tests * fix node 12 bug Co-authored-by: Robert Nagy <ronagy@icloud.com>
continuation of #363
closes #198