Diff
Not logged in

Differences From:

File src/cgi.c part of check-in [d8ceb4ad47] - The "ui" and "server" commands no longer quit if they cannot open TCP port 8080. They keep trying with consecutive ports until they find one that works - up to 100 ports. by drh on 2008-11-10 01:13:35. [view]

To:

File src/cgi.c part of check-in [f6a071cef1] - Omit the Content-Length header line from the CGI response under windows because subsequent \n to \r\n translations by Apache will change the content length. But keep the Content-Length header line for the built-in servers and under unix. Ticket c62fac40af0. by drh on 2008-11-18 02:21:00. Also file src/cgi.c part of check-in [d14adf1032] - Merge src & doc leaves back. by kejoki on 2008-11-19 16:55:14. [view]

@@ -337,9 +337,25 @@
   }
 
   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, "\r\n");
   if( total_size>0 && iReplyStatus != 304 ){
     int i, size;