feat/ns http
Merged
VA
4mo ago+2025+2025+0123456789012345678901234567890123456789-82-82-01234567890123456789
Implement memory-safe synchronous HTTP client
Introduces the ns_http module, wrapping Rust's reqwest crate to provide
a modern, synchronous HTTP API to C without the complexity and callback
management of libcurl.
Key additions:
- Implemented
ns_http_getandns_http_postfor standard web requests. - Added
ns_http_responsestruct to cleanly capture HTTP status codes and
pack the response body directly into memory-safe SSOns_stringstructs. - Introduced the
ns_autohttpmacro, leveraging the GCC/Clang cleanup
attribute to provide RAII, automatically freeing HTTP response buffers
when they fall out of scope. - Created
18_http.cexample demonstrating fetching
data and pushing JSON payloads. - Registered
ns_httpcrate in the workspace and addedreqwestdependency.
Summary by cubic
Adds a new ns_http module with a simple, memory-safe synchronous HTTP client for C. Supports GET/POST with RAII cleanup; POST is binary‑safe and GET/POST now share a unified client configuration.
-
New Features
- New
ns_httpcrate using blockingreqwestwith a browser-like User-Agent. ns_http_getandns_http_post; results vians_http_response(status +ns_stringbody).ns_autohttpmacro for auto-free; headerinclude/ns_http.h; exampleexamples/18_http.c; Makefile links-lns_http.
- New
-
Bug Fixes
- POST: binary-safe payloads (raw bytes) and null payloads return
NsError::InvalidInput. - GET: response decoding errors now return generic
NsError::Any. - Centralized client configuration to prevent drift between GET and POST.
- Makefile
uninstallusesLIBS_TO_INSTALLto remove all installed libs.
- POST: binary-safe payloads (raw bytes) and null payloads return