aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-27 02:49:48 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-27 02:49:48 +0200
commit4f1f932f6ef6d6c9770266775c2db072964d7a62 (patch)
tree9301ae91ff298fea8ef5aaa3ece9362b8ccd227c /src
parent9407f040660c2e9bf8fda06b7e5b14e34d84cd8a (diff)
downloadblogc-4f1f932f6ef6d6c9770266775c2db072964d7a62.tar.gz
blogc-4f1f932f6ef6d6c9770266775c2db072964d7a62.tar.bz2
blogc-4f1f932f6ef6d6c9770266775c2db072964d7a62.zip
runserver: always reply with content-length
Diffstat (limited to 'src')
-rw-r--r--src/blogc-runserver/httpd.c6
1 files changed, 4 insertions, 2 deletions
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"
- "<h1>%s</h1>\n", status_code, error, error);
+ "<h1>%s</h1>\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) {