core: net/http_client — libcurl multi wrapper (stage 2)

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
This commit is contained in:
2026-09-09 23:31:09 +04:00
co-authored by Claude Sonnet 5
parent e442c99130
commit bd1bc029f3
9 changed files with 1369 additions and 4 deletions
+8 -4
View File
@@ -5,16 +5,20 @@
# `add_subdirectory(core)` in the root CMakeLists.txt (see core/docs/pkg-requests-m1.md).
find_package(Threads REQUIRED)
find_package(CURL 8.0 REQUIRED)
add_library(veloxcore STATIC
src/util/error.cpp
src/util/log.cpp
src/util/thread_pool.cpp
src/net/curl_error.cpp
src/net/http_client.cpp
)
add_library(velox::core ALIAS veloxcore)
target_include_directories(veloxcore PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
target_include_directories(veloxcore
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src # net/*.cpp -> "net/curl_error.hpp"
)
target_compile_features(veloxcore PUBLIC cxx_std_23)
@@ -25,9 +29,9 @@ target_compile_options(veloxcore PRIVATE
-Wall -Wextra -Wpedantic -Werror
)
target_link_libraries(veloxcore PUBLIC Threads::Threads)
target_link_libraries(veloxcore PUBLIC Threads::Threads CURL::libcurl)
# Later stages add: find_package(CURL 8.0) for net/, find_package(OpenSSL) for meta/.
# Later stages add: find_package(OpenSSL) for meta/ (streaming SHA-256 + resume CRC).
if(VELOX_BUILD_TESTS)
add_subdirectory(tests)