hermes

HTTP GET/HEAD-only web server for static content.
git clone git://git.francescosaccone.com/hermes
Log | Files | Refs | README | LICENSE

commit 3240beae6da1996c7344f5e9dc3adf0df861240d
parent c8d13f9ec93bd7bd40c59bff42b17951579eaf74
Author: Francesco Saccone <francesco@francescosaccone.com>
Date:   Mon, 31 Mar 2025 18:21:32 +0200

refactor: make compose_http_response use stack instead of heap

Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>

Diffstat:
Mhttp.c | 12++++++------
Mhttp.h | 2+-
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/http.c b/http.c @@ -36,7 +36,7 @@ parse_http_request(char *request) { } void -compose_http_response(struct http_response *response, +compose_http_response(struct http_response response, char *buffer, unsigned int buffer_size) { snprintf(buffer, buffer_size, "HTTP/1.1 %u %s\r\n" @@ -44,9 +44,9 @@ compose_http_response(struct http_response *response, "Content-Length: %u\r\n" "\r\n" "%s", - status_map[response->status].code, - status_map[response->status].message, - response->content_type, - response->body_length, - response->body); + status_map[response.status].code, + status_map[response.status].message, + response.content_type, + response.body_length, + response.body); } diff --git a/http.h b/http.h @@ -88,7 +88,7 @@ parse_http_request(char *request); * Writes a raw HTTP response to buffer, given a http_response. */ void -compose_http_response(struct http_response *response, +compose_http_response(struct http_response response, char *buffer, unsigned int buffer_size);