From b6951c18912c82e7863ebd6c6c77b891ad9aea0c Mon Sep 17 00:00:00 2001 From: frosty Date: Sat, 8 Aug 2026 00:37:44 -0400 Subject: fix: centralise empty HTTP status responses --- src/routing.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/routing.c') diff --git a/src/routing.c b/src/routing.c index 55a6599..00886c8 100644 --- a/src/routing.c +++ b/src/routing.c @@ -265,9 +265,7 @@ bool serve_static_file_with_mime(const char *request_path_relative_to_static, co request_path_relative_to_static[0] == '/') { fprintf(stderr, "[SECURITY] Attempted directory traversal: %s\n", request_path_relative_to_static); - const char *forbidden_response = - "HTTP/1.1 403 Forbidden\r\nContent-Length: 0\r\n\r\n"; - send(current_client_socket, forbidden_response, strlen(forbidden_response), 0); + send_status("403 Forbidden"); return true; } @@ -289,9 +287,7 @@ bool serve_static_file_with_mime(const char *request_path_relative_to_static, co fprintf(stderr, "[ERROR] serve_static_file_with_mime: fstat failed for '%s'.\n", full_static_path); fclose(fp); - const char *server_error_response = - "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n"; - send(current_client_socket, server_error_response, strlen(server_error_response), 0); + send_status("500 Internal Server Error"); return true; } -- cgit v1.3