ygrek / ocurl

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

Add special pause variables. #43

Closed toots closed 2 years ago

toots commented 3 years ago

This PR adds the two special variables used to signal the library to pause read and write transfers.

toots commented 3 years ago

Yes, that's correct. I was more curious about your idea to make it work.

On Fri, May 28, 2021, 11:40 AM ygrek @.***> wrote:

@.**** commented on this pull request.

In curl.mli https://github.com/ygrek/ocurl/pull/43#discussion_r641681270 :

val set_writefunction : t -> (string -> int) -> unit + +( Return this value to pause the read transfers. ) +val readfunc_pause : int

READFUNCTION callback returns string, so it is not possible to return int value there, unless I am missing something.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ygrek/ocurl/pull/43#discussion_r641681270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUVFDI4GMZNUCYHD7CZPDTP7BQ7ANCNFSM45TQNCOA .

ygrek commented 3 years ago

add CURLOPT_READ of type int -> read_result where read_result = String of string | Substring of string * int * int (* if we want to get fancy *) | Abort | Pause and map it to the same CURLOPT_READFUNCTION on C side (keeping CURLOPT_READFUNCTION variant intact). Same for write.

toots commented 3 years ago

Gotcha, will do thanks!

toots commented 3 years ago

I looked into it and it's actually pretty tricky. The way the code is structured to implicitly create the handlers for each define doesn't really allow for two alternative names for the read callback. I might just restrict it to the write callback, in which case it is pretty easy to define the alternative callback at the OCaml level.

ygrek commented 2 years ago

implemented in https://github.com/ygrek/ocurl/commit/0c84f7c4c6a3ff60c3a8543839fdb07f3d767b3c