1#define KURLYK_AUTO_INIT 0
12 std::promise<void> done_promise;
13 auto done_future = done_promise.get_future();
14 std::atomic<int> chunk_count(0);
17 "http://httpbin.org/stream/5",
22 if (!response)
return;
24 if (response->stream_chunk) {
26 KURLYK_PRINT <<
"chunk: " << response->content << std::endl;
29 if (!response->ready)
return;
32 <<
"ready: " << std::boolalpha << response->ready << std::endl
33 <<
"status_code: " << response->status_code << std::endl
34 <<
"chunks: " << chunk_count.load() << std::endl
35 <<
"error_code: " << response->error_code.message() << std::endl;
38 done_promise.set_value();
43 KURLYK_PRINT <<
"Request id: " << request_id << std::endl;
44 done_future.wait_for(std::chrono::seconds(30));
Main header file for the Kurlyk library, providing HTTP and WebSocket support.
void init(const bool use_async=true)
Initializes the Kurlyk library, setting up necessary managers and the network worker.
std::unique_ptr< HttpResponse > HttpResponsePtr
A unique pointer to an HttpResponse object for memory management.
void deinit()
Deinitializes the Kurlyk library, stopping async processing or cleaning up synchronous state.
utils::CaseInsensitiveMultimap Headers
Alias for HTTP headers, providing a case-insensitive unordered multimap.
uint64_t http_get(const std::string &url, const QueryParams &query, const Headers &headers, HttpResponseCallback callback)
Sends an asynchronous HTTP GET request with a callback.
utils::CaseInsensitiveMultimap QueryParams
Alias for query parameters in HTTP requests, stored case-insensitively.