feat/ns http

Merged
VA
4mo ago
+2025-82

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_get and ns_http_post for standard web requests.
  • Added ns_http_response struct to cleanly capture HTTP status codes and
    pack the response body directly into memory-safe SSO ns_string structs.
  • Introduced the ns_autohttp macro, leveraging the GCC/Clang cleanup
    attribute to provide RAII, automatically freeing HTTP response buffers
    when they fall out of scope.
  • Created 18_http.c example demonstrating fetching
    data and pushing JSON payloads.
  • Registered ns_http crate in the workspace and added reqwest dependency.

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_http crate using blocking reqwest with a browser-like User-Agent.
    • ns_http_get and ns_http_post; results via ns_http_response (status + ns_string body).
    • ns_autohttp macro for auto-free; header include/ns_http.h; example examples/18_http.c; Makefile links -lns_http.
  • 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 uninstall uses LIBS_TO_INSTALL to remove all installed libs.