diff src/c/urweb.c @ 1934:420d129c4174

HTTP: avoid duplicate Content-length
author Adam Chlipala <adam@chlipala.net>
date Thu, 12 Dec 2013 10:24:38 -0500
parents 8e6e3d9cea22
children 6745eafff617
line wrap: on
line diff
--- a/src/c/urweb.c	Wed Dec 11 18:54:42 2013 -0500
+++ b/src/c/urweb.c	Thu Dec 12 10:24:38 2013 -0500
@@ -1347,6 +1347,10 @@
   ctx->outHeaders.front += len;
 }
 
+int uw_has_contentLength(uw_context ctx) {
+  return strstr(ctx->outHeaders.start, "Content-length: ") != NULL;
+}
+
 void uw_clear_headers(uw_context ctx) {
   uw_buffer_reset(&ctx->outHeaders);
 }
@@ -3723,7 +3727,7 @@
   uw_write_header(ctx, on_success);
   uw_write_header(ctx, "Content-Type: ");
   uw_write_header(ctx, mimeType);
-  uw_write_header(ctx, "\r\nContent-Length: ");
+  uw_write_header(ctx, "\r\nContent-length: ");
   ctx_uw_buffer_check(ctx, "headers", &ctx->outHeaders, INTS_MAX);
   sprintf(ctx->outHeaders.front, "%lu%n", (unsigned long)b.size, &len);
   ctx->outHeaders.front += len;
@@ -3755,7 +3759,7 @@
   uw_write_header(ctx, on_success);
   uw_write_header(ctx, "Content-Type: ");
   uw_write_header(ctx, mimeType);
-  uw_write_header(ctx, "\r\nContent-Length: ");
+  uw_write_header(ctx, "\r\nContent-length: ");
   ctx_uw_buffer_check(ctx, "headers", &ctx->outHeaders, INTS_MAX);
   sprintf(ctx->outHeaders.front, "%lu%n", (unsigned long)uw_buffer_used(&ctx->page), &len);
   ctx->outHeaders.front += len;