Fossil SCM

Here is a better fix for ticket [c62fac40af] suggested by Kees Nuyt.

drh 2008-11-20 00:35 trunk
Commit 22cb1e1be2d1636a8e4dc106d081a5100610fe79
2 files changed +1 -17 +7
+1 -17
--- src/cgi.c
+++ src/cgi.c
@@ -336,27 +336,11 @@
336336
blob_compress(&cgiContent[0], &cgiContent[0]);
337337
}
338338
339339
if( iReplyStatus != 304 ) {
340340
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
341
-#ifdef __MINGW32__
342
- /* In windows versions of Apache, extra \r characters get added to the
343
- ** response, which mess up the Content-Length. So let apache figure
344
- ** out the content length for itself if we are using CGI. If this
345
- ** is a complete stand-alone webserver, on the other hand, we still
346
- ** need the Content-Length.
347
- */
348
- if( g.fullHttpReply ){
349
- fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
350
- }
351
-#else
352
- /* On unix, \n to \r\n translation is never a problem. We know the
353
- ** content length, so we might as well go ahead and tell the webserver
354
- ** what it is in all cases.
355
- */
356
- fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
357
-#endif
341
+ fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
358342
}
359343
fprintf(g.httpOut, "\r\n");
360344
if( total_size>0 && iReplyStatus != 304 ){
361345
int i, size;
362346
for(i=0; i<2; i++){
363347
--- src/cgi.c
+++ src/cgi.c
@@ -336,27 +336,11 @@
336 blob_compress(&cgiContent[0], &cgiContent[0]);
337 }
338
339 if( iReplyStatus != 304 ) {
340 total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
341 #ifdef __MINGW32__
342 /* In windows versions of Apache, extra \r characters get added to the
343 ** response, which mess up the Content-Length. So let apache figure
344 ** out the content length for itself if we are using CGI. If this
345 ** is a complete stand-alone webserver, on the other hand, we still
346 ** need the Content-Length.
347 */
348 if( g.fullHttpReply ){
349 fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
350 }
351 #else
352 /* On unix, \n to \r\n translation is never a problem. We know the
353 ** content length, so we might as well go ahead and tell the webserver
354 ** what it is in all cases.
355 */
356 fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
357 #endif
358 }
359 fprintf(g.httpOut, "\r\n");
360 if( total_size>0 && iReplyStatus != 304 ){
361 int i, size;
362 for(i=0; i<2; i++){
363
--- src/cgi.c
+++ src/cgi.c
@@ -336,27 +336,11 @@
336 blob_compress(&cgiContent[0], &cgiContent[0]);
337 }
338
339 if( iReplyStatus != 304 ) {
340 total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
341 fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342 }
343 fprintf(g.httpOut, "\r\n");
344 if( total_size>0 && iReplyStatus != 304 ){
345 int i, size;
346 for(i=0; i<2; i++){
347
+7
--- src/main.c
+++ src/main.c
@@ -26,10 +26,11 @@
2626
*/
2727
#include "config.h"
2828
#include "main.h"
2929
#include <string.h>
3030
#include <time.h>
31
+#include <fcntl.h>
3132
3233
#if INTERFACE
3334
3435
/*
3536
** Number of elements in an array
@@ -608,10 +609,16 @@
608609
}else{
609610
zFile = g.argv[1];
610611
}
611612
g.httpOut = stdout;
612613
g.httpIn = stdin;
614
+#ifdef __MINGW32__
615
+ /* Set binary mode on windows to avoid undesired translations
616
+ ** between \n and \r\n. */
617
+ setmode(_fileno(g.httpOut), _O_BINARY);
618
+ setmode(_fileno(g.httpIn), _O_BINARY);
619
+#endif
613620
g.cgiPanic = 1;
614621
blob_read_from_file(&config, zFile);
615622
while( blob_line(&config, &line) ){
616623
if( !blob_token(&line, &key) ) continue;
617624
if( blob_buffer(&key)[0]=='#' ) continue;
618625
--- src/main.c
+++ src/main.c
@@ -26,10 +26,11 @@
26 */
27 #include "config.h"
28 #include "main.h"
29 #include <string.h>
30 #include <time.h>
 
31
32 #if INTERFACE
33
34 /*
35 ** Number of elements in an array
@@ -608,10 +609,16 @@
608 }else{
609 zFile = g.argv[1];
610 }
611 g.httpOut = stdout;
612 g.httpIn = stdin;
 
 
 
 
 
 
613 g.cgiPanic = 1;
614 blob_read_from_file(&config, zFile);
615 while( blob_line(&config, &line) ){
616 if( !blob_token(&line, &key) ) continue;
617 if( blob_buffer(&key)[0]=='#' ) continue;
618
--- src/main.c
+++ src/main.c
@@ -26,10 +26,11 @@
26 */
27 #include "config.h"
28 #include "main.h"
29 #include <string.h>
30 #include <time.h>
31 #include <fcntl.h>
32
33 #if INTERFACE
34
35 /*
36 ** Number of elements in an array
@@ -608,10 +609,16 @@
609 }else{
610 zFile = g.argv[1];
611 }
612 g.httpOut = stdout;
613 g.httpIn = stdin;
614 #ifdef __MINGW32__
615 /* Set binary mode on windows to avoid undesired translations
616 ** between \n and \r\n. */
617 setmode(_fileno(g.httpOut), _O_BINARY);
618 setmode(_fileno(g.httpIn), _O_BINARY);
619 #endif
620 g.cgiPanic = 1;
621 blob_read_from_file(&config, zFile);
622 while( blob_line(&config, &line) ){
623 if( !blob_token(&line, &key) ) continue;
624 if( blob_buffer(&key)[0]=='#' ) continue;
625

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button