A small libssl-backed client (naut_http_get) that fetches a URL over plain HTTP or TLS, follows 3xx redirects, and decodes Content-Length and chunked bodies. Foundation for the RSS poller and Torznab search. Built as a PIC static lib so it can link into the webui plugin module. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
1.1 KiB
C
26 lines
1.1 KiB
C
/* http_client.h — minimal blocking HTTP/HTTPS GET client.
|
|
*
|
|
* Used by the web UI for RSS feed polling and Torznab indexer search. Supports
|
|
* plain HTTP and TLS (via OpenSSL), follows redirects, and returns the decoded
|
|
* response body. Intended for occasional fetches off the hot path. */
|
|
#ifndef NAUT_HTTP_CLIENT_H
|
|
#define NAUT_HTTP_CLIENT_H
|
|
|
|
#include <stddef.h>
|
|
#include "naut/common.h"
|
|
|
|
typedef struct {
|
|
long status; /* HTTP status code (e.g. 200) */
|
|
char *body; /* malloc'd, NUL-terminated response body */
|
|
size_t body_len; /* length of body, excluding the NUL */
|
|
} naut_http_response;
|
|
|
|
/* GET `url` (http:// or https://), following up to a handful of redirects.
|
|
* On NAUT_OK, `out` owns `out->body` (free with naut_http_response_free).
|
|
* Returns NAUT_ERR_* on transport/protocol failure. A non-2xx HTTP status is
|
|
* still returned as NAUT_OK with out->status set, so callers can inspect it. */
|
|
naut_err naut_http_get(const char *url, naut_http_response *out);
|
|
|
|
void naut_http_response_free(naut_http_response *r);
|
|
|
|
#endif /* NAUT_HTTP_CLIENT_H */
|