diff src/c/http.c @ 1915:52e88e139b25

Add Connection and Content-length headers to raw HTTP responses
author Adam Chlipala <adam@chlipala.net>
date Wed, 27 Nov 2013 15:28:55 -0500
parents 6a2cc604a322
children 398298ca82b9
line wrap: on
line diff
--- a/src/c/http.c	Wed Nov 27 08:59:57 2013 -0500
+++ b/src/c/http.c	Wed Nov 27 15:28:55 2013 -0500
@@ -204,7 +204,14 @@
                         on_success, on_failure,
                         NULL, log_error, log_debug,
                         sock, uw_really_send, close);
-        if (rr != KEEP_OPEN) uw_send(ctx, sock);
+        if (rr != KEEP_OPEN) {
+          char clen[100];
+
+          uw_write_header(ctx, "Connection: close\r\n");
+          sprintf(clen, "Content-length: %d\r\n", uw_pagelen(ctx));
+          uw_write_header(ctx, clen);
+          uw_send(ctx, sock);
+        }
 
         if (rr == SERVED || rr == FAILED)
           close(sock);