ygrek / ocurl

OCaml bindings to libcurl
https://ygrek.org/p/ocurl
MIT License
60 stars 32 forks source link

Support for magic return codes in read and write functions #39

Closed dwwoelfel closed 2 years ago

dwwoelfel commented 4 years ago

libcurl supports returning CURL_READFUNC_PAUSE from the read function and CURL_WRITEFUNC_PAUSE from the write function.

If you return the magic value instead of the number of bytes that were read/written, then libcurl will try again with the same data after you unpause.

This would be very helpful to have for the read function especially. With the write function, users can usually handle a little bit of overflow after they call pause. It's much more complicated with the read function. If you don't have the data available to write, then you'll have to return 0 and the transfer will end.

ygrek commented 3 years ago

ftr https://github.com/ygrek/ocurl/pull/43