Check-in [f6a071cef1]
Not logged in
Overview

SHA1 Hash:f6a071cef15eef95fb2d8a896989a39ec46d8024
Date: 2008-11-18 02:21:00
User: drh
Comment: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.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/cgi.c from [40d3404d8c] to [e524bac009].

@@ -336,11 +336,27 @@
     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, "\r\n");
   if( total_size>0 && iReplyStatus != 304 ){
     int i, size;
     for(i=0; i<2; i++){