Open ChrisDirkis opened 1 year ago
@ChrisDirkis Thanks for creating this feature request. I agree, this would be a nice feature. Performing an async
request is minimal more expensive but definitely the way to go here.
Else you could use the ProgressCallback
and just return false
based on a specific flag you store in your code. Docs: https://docs.libcpr.org/advanced-usage.html#setting-callbacks
I will add it onto the TODO list for our next release.
Is your feature request related to a problem?
I'm trying to implement request cancellation for some requests done via GetCallback. Historically, we'd have a shared_ptr to a flag that's then checked in the callback, but I noticed that 1.10 had some cancellation semantics, so I was interested in using those instead. However, it appears that GetCallback and friends don't support cancellation, only MultiGetAsync and friends do.
Possible Solution
I'd like to see GetCallback be cancellable as MultiGetAsync is. It seems like cpr::async could return
AsyncWrapper<T, true>
, but the trivial change didn't compile and I haven't looked further into it.Alternatively, I'd be happy to use MultiGetCallback with 1 request, if such existed.
Alternatives
For now, we can solve this on our end with some shared flag checked in the callback.
Additional Context
No response