From 4f1f932f6ef6d6c9770266775c2db072964d7a62 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 27 Sep 2016 02:49:48 +0200 Subject: runserver: always reply with content-length --- src/blogc-runserver/httpd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/blogc-runserver') diff --git a/src/blogc-runserver/httpd.c b/src/blogc-runserver/httpd.c index c10a365..c2fd259 100644 --- a/src/blogc-runserver/httpd.c +++ b/src/blogc-runserver/httpd.c @@ -50,9 +50,10 @@ error(int socket, int status_code, const char *error) char *str = bc_strdup_printf( "HTTP/1.0 %d %s\r\n" "Content-Type: text/html\r\n" + "Content-Length: %zu\r\n" "Connection: close\r\n" "\r\n" - "

%s

\n", status_code, error, error); + "

%s

\n", status_code, error, strlen(error) + 10, error); if (write(socket, str, strlen(str)) == -1) { // do nothing, just avoid warnig } @@ -160,6 +161,7 @@ handle_request(void *arg) char *tmp = bc_strdup_printf( "HTTP/1.0 302 Found\r\n" "Location: %s/\r\n" + "Content-Length: 0\r\n" "Connection: close\r\n" "\r\n", path); status_code = 302; @@ -183,7 +185,7 @@ handle_request(void *arg) char *out = bc_strdup_printf( "HTTP/1.0 200 OK\r\n" "Content-Type: %s\r\n" - "Content-Length: %d\r\n" + "Content-Length: %zu\r\n" "Connection: close\r\n" "\r\n", br_mime_guess_content_type(real_path), len); if (write(client_socket, out, strlen(out)) == -1) { -- cgit v1.2.3-18-g5258