hermes

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

commit af604046704aefa22efa536a3a8217ac99b9b3f2
parent cf1d89aadc0ab05c0941fcc2eb552dfa24665f2d
Author: Francesco Saccone <francesco@francescosaccone.com>
Date:   Mon, 31 Mar 2025 19:27:15 +0200

refactor: make struct http_response not need body_length

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

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

diff --git a/http.c b/http.c @@ -50,8 +50,7 @@ get_length_of_integer(unsigned int integer) { void compose_http_response(struct http_response response, char *buffer) { size_t size; - unsigned int status_code = status_map[response.status].code, - body_length = response.body_length; + unsigned int status_code = status_map[response.status].code; const char *template = "HTTP/1.1 %u %s\r\n" "Content-Type: %s; charset=UTF-8\r\n" "Content-Length: %u\r\n" @@ -71,7 +70,7 @@ compose_http_response(struct http_response response, char *buffer) { + get_length_of_integer(status_code) + strlen(status_message) + strlen(content_type) - + get_length_of_integer(body_length) + + get_length_of_integer(strlen(body)) + strlen(body) - 2 * 5; @@ -79,6 +78,6 @@ compose_http_response(struct http_response response, char *buffer) { status_code, status_message, content_type, - body_length, + strlen(body), body); } diff --git a/http.h b/http.h @@ -78,7 +78,6 @@ struct http_response { enum http_response_status status; const char *content_type; char *body; - unsigned int body_length; }; struct http_request *