Closed qwertynat closed 3 years ago
I hadn't really ever considered using curl for lift in this manner with custom protocols after connecting, my original use case was extremely high throughput on a background event loop (async) http requests and try an easy to use safe API.
However, it is probably possible but right now lift is definitely not setup to work this way at the moment. Currently you build out the entire HTTP request and then either synchronously perform the request (low throughput requirements) or you have to std::move()
the request into the lift::client
and it takes ownership until the request completes or times out/errors. This would probably require some kind of shared ownership or special request type to do this with the lift::client
asynchronously, but would probably be fairly simple to add to synchronous requests.
I would assume this use case would be a duplex send/recv arbitrarily on the stream or would it be send -> recv -> send -> recv in a consistent pattern where ownership could still be passed back and forth between the userland and the library land? If the former then async callbacks would need to be able to happen many times -- right now the on complete callback std::move()
's the request and response objects back to the user of the library to return ownership.
I'm going to close this ticket since its now been over a month and I'm not sure I want to add this into the API for this library.
Hi,
Just wondering is it possible to also use this library to also receive data from a streaming socket?
As an example i have a stream of data ( {JSON DATA}\r\n{JSON DATA}\r\n{JSON DATA}\r\n ... )
how i currently receive it using lib curl would be like follows:
curl_easysetopt(handles, CURLOPT_URL, "https://test.com"); curl_easysetopt(handles, CURLOPT_CONNECT_ONLY, 1L);
( then to receive, i call the below which gets called from my event loop when epoll notices there is ) curl_easyrecv(handles, readbuf, sizeof(readbuf), &nread_);
with liblifthttp would i be able to set up my socket as normal and get callbacks when there is data ready ?
Thanks!