Fossil SCM
Here is a better fix for ticket [c62fac40af] suggested by Kees Nuyt.
Commit
22cb1e1be2d1636a8e4dc106d081a5100610fe79
Parent
53db94cd41f9eea…
2 files changed
+1
-17
+7
+1
-17
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -336,27 +336,11 @@ | ||
| 336 | 336 | blob_compress(&cgiContent[0], &cgiContent[0]); |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | if( iReplyStatus != 304 ) { |
| 340 | 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 | |
| 341 | + fprintf(g.httpOut, "Content-Length: %d\r\n", total_size); | |
| 358 | 342 | } |
| 359 | 343 | fprintf(g.httpOut, "\r\n"); |
| 360 | 344 | if( total_size>0 && iReplyStatus != 304 ){ |
| 361 | 345 | int i, size; |
| 362 | 346 | for(i=0; i<2; i++){ |
| 363 | 347 |
| --- 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 @@ | ||
| 26 | 26 | */ |
| 27 | 27 | #include "config.h" |
| 28 | 28 | #include "main.h" |
| 29 | 29 | #include <string.h> |
| 30 | 30 | #include <time.h> |
| 31 | +#include <fcntl.h> | |
| 31 | 32 | |
| 32 | 33 | #if INTERFACE |
| 33 | 34 | |
| 34 | 35 | /* |
| 35 | 36 | ** Number of elements in an array |
| @@ -608,10 +609,16 @@ | ||
| 608 | 609 | }else{ |
| 609 | 610 | zFile = g.argv[1]; |
| 610 | 611 | } |
| 611 | 612 | g.httpOut = stdout; |
| 612 | 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 | |
| 613 | 620 | g.cgiPanic = 1; |
| 614 | 621 | blob_read_from_file(&config, zFile); |
| 615 | 622 | while( blob_line(&config, &line) ){ |
| 616 | 623 | if( !blob_token(&line, &key) ) continue; |
| 617 | 624 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 618 | 625 |
| --- 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 |