--- a/src/server/proxy/httpclient.h Sun Feb 15 13:30:29 2026 +0100 +++ b/src/server/proxy/httpclient.h Mon Feb 16 17:43:14 2026 +0100 @@ -37,6 +37,8 @@ #include <cx/mempool.h> #include <cx/test.h> +#include <inttypes.h> + #ifdef __cplusplus extern "C" { #endif @@ -61,17 +63,27 @@ HeaderArray *request_headers; HeaderArray *response_headers; + /* + * request content length + * 0: no request body + * > 0: request body with static length + * -1: request body with chunked transfer encoding + */ + int64_t req_content_length; + int error; int statuscode; /* * Request body callback function * - * size_t request_body_read(HttpClient *client, void *buf, size_t size, void *userdata) + * ssize_t request_body_read(HttpClient *client, void *buf, size_t size, void *userdata) + * + * Return: number of processed bytes, + * HTTP_CLIENT_CALLBACK_WOULD_BLOCK or HTTP_CLIENT_CALLBACK_ERROR. */ - // TODO: fix, doesn't work this way - //size_t (*request_body_read)(HttpClient *, void *, size_t, void *); - //void *request_body_read_userdata; + ssize_t (*request_body_read)(HttpClient *, void *, size_t, void *); + void *request_body_read_userdata; /* * Response start callback function @@ -109,9 +121,12 @@ netbuf buffer; char *req_buffer; + size_t req_buffer_alloc; size_t req_buffer_len; size_t req_buffer_pos; + size_t req_contentlength_pos; + int request_body_complete; int header_complete; Event readev; @@ -148,6 +163,16 @@ */ int http_client_add_request_header_copy(HttpClient *client, cxstring name, cxstring value); +/* + * Sets the content length for the request body + */ +int http_client_set_content_length(HttpClient *client, int64_t contentlength); + +/* + * Enables a request body with a chunked transfer encoding + */ +int http_client_enable_chunked_transfer_encoding(HttpClient *client); + int http_client_start(HttpClient *client);