r-lib / httr2

Make HTTP requests and process their responses. A modern reimagining of httr.
https://httr2.r-lib.org
Other
238 stars 59 forks source link

Allow `req_perform_stream()` to perform non-blocking reads #520

Closed hadley closed 2 months ago

hadley commented 2 months ago

The default behaviour stays the same, but you can now specify wait_for in order to switch to a non-blocking request and call the callback as the data arrives.

Fixes #519

@jcheng5 Does that feel like the right argument name? I have kept the behaviour the same as previously, but maybe the default should be wait_for = 0? Does the wait_for implementation loop look ok to you?

jcheng5 commented 2 months ago

Have you tried this with a real SSE server and do you end up with an extra callback with "\n" at the end? If "yes" and "no", LGTM!