One HttpClient owns a small pool of workers, each with its own CURLM; an easy handle lives on one worker for its life. Public start/pause/resume/ cancel enqueue a command + curl_multi_wakeup(); callbacks (on_head / on_data / on_finished) run on the worker thread and return a DataAction (proceed / pause / abort). Covers redirects (final-response head only), ranges (inclusive ByteRange -> CURLOPT_RANGE), proxy/SOCKS5, basic/digest auth, cookies, verbatim headers, stall detection, a coarse recv-rate cap, and a curl_share DNS/TLS cache across workers. CURLcode + HTTP status -> vdm::Error in net/curl_error. A probe is on_head returning abort: it finishes successfully (head_complete), not canceled. Tests drive tools/testserver: full GET, ranged 206, redirect chain, 404 -> not_found, connection refused -> connect_failed, HEAD probe + ranged 0-0 probe (no body), cancel mid-transfer, pause/resume completes. Skip cleanly if testserver isn't in the tree. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HPPSGhiArbvQgwC2DNiURS
25 lines
831 B
C++
25 lines
831 B
C++
// vdm/net/curl_error.hpp — internal: CURLcode -> vdm::Error. Not a public header.
|
|
|
|
#ifndef VDM_NET_CURL_ERROR_HPP
|
|
#define VDM_NET_CURL_ERROR_HPP
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <string>
|
|
|
|
#include "vdm/util/error.hpp"
|
|
|
|
namespace vdm::net::detail {
|
|
|
|
// Map a libcurl transfer result to the engine taxonomy. `http_status` (0 if none) lets
|
|
// the HTTP-status errors (403/404/416/...) be classified here too; pass it from
|
|
// CURLINFO_RESPONSE_CODE. `CURLE_OK` with a >= 400 status still yields an error.
|
|
[[nodiscard]] Error error_from_curl(CURLcode code, long http_status) noexcept;
|
|
|
|
// A human-readable ErrorInfo, folding in curl's own message and the status.
|
|
[[nodiscard]] ErrorInfo make_error(CURLcode code, long http_status, const char *curl_msg = nullptr);
|
|
|
|
} // namespace vdm::net::detail
|
|
|
|
#endif // VDM_NET_CURL_ERROR_HPP
|