Check-in [22cb1e1be2]
Not logged in
Overview

SHA1 Hash:22cb1e1be2d1636a8e4dc106d081a5100610fe79
Date: 2008-11-20 00:35:23
User: drh
Comment:Here is a better fix for ticket c62fac40af suggested by Kees Nuyt.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/cgi.c from [ab524199ae] to [9bee6fb4ef].

@@ -336,27 +336,11 @@
     blob_compress(&cgiContent[0], &cgiContent[0]);
   }
 
   if( iReplyStatus != 304 ) {
     total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
-#ifdef __MINGW32__
-    /* In windows versions of Apache, extra \r characters get added to the
-    ** response, which mess up the Content-Length.  So let apache figure
-    ** out the content length for itself if we are using CGI.  If this
-    ** is a complete stand-alone webserver, on the other hand, we still
-    ** need the Content-Length.
-    */
-    if( g.fullHttpReply ){
-      fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
-    }
-#else
-    /* On unix, \n to \r\n translation is never a problem.  We know the
-    ** content length, so we might as well go ahead and tell the webserver
-    ** what it is in all cases.
-    */
-    fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
-#endif
+    fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
   }
   fprintf(g.httpOut, "\r\n");
   if( total_size>0 && iReplyStatus != 304 ){
     int i, size;
     for(i=0; i<2; i++){

Modified src/main.c from [ce8e26c45d] to [815f70292e].

@@ -26,10 +26,11 @@
 */
 #include "config.h"
 #include "main.h"
 #include <string.h>
 #include <time.h>
+#include <fcntl.h>
 
 #if INTERFACE
 
 /*
 ** Number of elements in an array
@@ -608,10 +609,16 @@
   }else{
     zFile = g.argv[1];
   }
   g.httpOut = stdout;
   g.httpIn = stdin;
+#ifdef __MINGW32__
+  /* Set binary mode on windows to avoid undesired translations
+  ** between \n and \r\n. */
+  setmode(_fileno(g.httpOut), _O_BINARY);
+  setmode(_fileno(g.httpIn), _O_BINARY);
+#endif
   g.cgiPanic = 1;
   blob_read_from_file(&config, zFile);
   while( blob_line(&config, &line) ){
     if( !blob_token(&line, &key) ) continue;
     if( blob_buffer(&key)[0]=='#' ) continue;