Fossil SCM

Add the --nocompress option to the "ui", "server", and "http" commands. This option prevents HTTP reply compression, which is useful during debugging. The option is on by default for "test-http". Also, make sure the mimetype for error messages is set to text/html.

drh 2018-07-14 14:13 trunk
Commit cfc7aca2c1b573add275ceac2d3055b48800ecb9a19f7a4316464c2da5315674
+3 -7
--- src/cgi.c
+++ src/cgi.c
@@ -236,10 +236,11 @@
236236
237237
/*
238238
** Return true if the response should be sent with Content-Encoding: gzip.
239239
*/
240240
static int is_gzippable(void){
241
+ if( g.fNoHttpCompress ) return 0;
241242
if( strstr(PD("HTTP_ACCEPT_ENCODING", ""), "gzip")==0 ) return 0;
242243
return strncmp(zContentType, "text/", 5)==0
243244
|| sqlite3_strglob("application/*xml", zContentType)==0
244245
|| sqlite3_strglob("application/*javascript", zContentType)==0;
245246
}
@@ -1474,16 +1475,11 @@
14741475
zVal[i] = 0;
14751476
for(i=0; zFieldName[i]; i++){
14761477
zFieldName[i] = fossil_tolower(zFieldName[i]);
14771478
}
14781479
if( fossil_strcmp(zFieldName,"accept-encoding:")==0 ){
1479
- /* Hack: Ignore the accept-encoding value (thus preventing the
1480
- ** output from being compressed) for the "fossil test-http" command.
1481
- ** This simplifies debugging. */
1482
- if( g.argc<2 || fossil_strncmp(g.argv[1],"test-http",9)!=0 ){
1483
- cgi_setenv("HTTP_ACCEPT_ENCODING", zVal);
1484
- }
1480
+ cgi_setenv("HTTP_ACCEPT_ENCODING", zVal);
14851481
}else if( fossil_strcmp(zFieldName,"content-length:")==0 ){
14861482
cgi_setenv("CONTENT_LENGTH", zVal);
14871483
}else if( fossil_strcmp(zFieldName,"content-type:")==0 ){
14881484
cgi_setenv("CONTENT_TYPE", zVal);
14891485
}else if( fossil_strcmp(zFieldName,"cookie:")==0 ){
@@ -1918,11 +1914,11 @@
19181914
fd = dup(connection);
19191915
if( fd!=0 ) nErr++;
19201916
close(1);
19211917
fd = dup(connection);
19221918
if( fd!=1 ) nErr++;
1923
- if( !g.fAnyTrace ){
1919
+ if( 0 && !g.fAnyTrace ){
19241920
close(2);
19251921
fd = dup(connection);
19261922
if( fd!=2 ) nErr++;
19271923
}
19281924
close(connection);
19291925
--- src/cgi.c
+++ src/cgi.c
@@ -236,10 +236,11 @@
236
237 /*
238 ** Return true if the response should be sent with Content-Encoding: gzip.
239 */
240 static int is_gzippable(void){
 
241 if( strstr(PD("HTTP_ACCEPT_ENCODING", ""), "gzip")==0 ) return 0;
242 return strncmp(zContentType, "text/", 5)==0
243 || sqlite3_strglob("application/*xml", zContentType)==0
244 || sqlite3_strglob("application/*javascript", zContentType)==0;
245 }
@@ -1474,16 +1475,11 @@
1474 zVal[i] = 0;
1475 for(i=0; zFieldName[i]; i++){
1476 zFieldName[i] = fossil_tolower(zFieldName[i]);
1477 }
1478 if( fossil_strcmp(zFieldName,"accept-encoding:")==0 ){
1479 /* Hack: Ignore the accept-encoding value (thus preventing the
1480 ** output from being compressed) for the "fossil test-http" command.
1481 ** This simplifies debugging. */
1482 if( g.argc<2 || fossil_strncmp(g.argv[1],"test-http",9)!=0 ){
1483 cgi_setenv("HTTP_ACCEPT_ENCODING", zVal);
1484 }
1485 }else if( fossil_strcmp(zFieldName,"content-length:")==0 ){
1486 cgi_setenv("CONTENT_LENGTH", zVal);
1487 }else if( fossil_strcmp(zFieldName,"content-type:")==0 ){
1488 cgi_setenv("CONTENT_TYPE", zVal);
1489 }else if( fossil_strcmp(zFieldName,"cookie:")==0 ){
@@ -1918,11 +1914,11 @@
1918 fd = dup(connection);
1919 if( fd!=0 ) nErr++;
1920 close(1);
1921 fd = dup(connection);
1922 if( fd!=1 ) nErr++;
1923 if( !g.fAnyTrace ){
1924 close(2);
1925 fd = dup(connection);
1926 if( fd!=2 ) nErr++;
1927 }
1928 close(connection);
1929
--- src/cgi.c
+++ src/cgi.c
@@ -236,10 +236,11 @@
236
237 /*
238 ** Return true if the response should be sent with Content-Encoding: gzip.
239 */
240 static int is_gzippable(void){
241 if( g.fNoHttpCompress ) return 0;
242 if( strstr(PD("HTTP_ACCEPT_ENCODING", ""), "gzip")==0 ) return 0;
243 return strncmp(zContentType, "text/", 5)==0
244 || sqlite3_strglob("application/*xml", zContentType)==0
245 || sqlite3_strglob("application/*javascript", zContentType)==0;
246 }
@@ -1474,16 +1475,11 @@
1475 zVal[i] = 0;
1476 for(i=0; zFieldName[i]; i++){
1477 zFieldName[i] = fossil_tolower(zFieldName[i]);
1478 }
1479 if( fossil_strcmp(zFieldName,"accept-encoding:")==0 ){
1480 cgi_setenv("HTTP_ACCEPT_ENCODING", zVal);
 
 
 
 
 
1481 }else if( fossil_strcmp(zFieldName,"content-length:")==0 ){
1482 cgi_setenv("CONTENT_LENGTH", zVal);
1483 }else if( fossil_strcmp(zFieldName,"content-type:")==0 ){
1484 cgi_setenv("CONTENT_TYPE", zVal);
1485 }else if( fossil_strcmp(zFieldName,"cookie:")==0 ){
@@ -1918,11 +1914,11 @@
1914 fd = dup(connection);
1915 if( fd!=0 ) nErr++;
1916 close(1);
1917 fd = dup(connection);
1918 if( fd!=1 ) nErr++;
1919 if( 0 && !g.fAnyTrace ){
1920 close(2);
1921 fd = dup(connection);
1922 if( fd!=2 ) nErr++;
1923 }
1924 close(connection);
1925
+6
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150150
int fAnyTrace; /* Any kind of tracing */
151151
char *zHttpAuth; /* HTTP Authorization user:pass information */
152152
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
153153
int fSshTrace; /* Trace the SSH setup traffic */
154154
int fSshClient; /* HTTP client flags for SSH client */
155
+ int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
155156
char *zSshCmd; /* SSH command string */
156157
int fNoSync; /* Do not do an autosync ever. --nosync */
157158
int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */
158159
char *zPath; /* Name of webpage being served */
159160
char *zExtra; /* Extra path information past the webpage name */
@@ -2274,10 +2275,11 @@
22742275
** --baseurl URL base URL (useful with reverse proxies)
22752276
** --files GLOB comma-separate glob patterns for static file to serve
22762277
** --localauth enable automatic login for local connections
22772278
** --host NAME specify hostname of the server
22782279
** --https signal a request coming in via https
2280
+** --nocompress Do not compress HTTP replies
22792281
** --nojail drop root privilege but do not enter the chroot jail
22802282
** --nossl signal that no SSL connections are available
22812283
** --notfound URL use URL as "HTTP 404, object not found" page.
22822284
** --repolist If REPOSITORY is directory, URL "/" lists all repos
22832285
** --scgi Interpret input as SCGI rather than HTTP
@@ -2319,10 +2321,11 @@
23192321
zNotFound = find_option("notfound", 0, 1);
23202322
noJail = find_option("nojail",0,0)!=0;
23212323
allowRepoList = find_option("repolist",0,0)!=0;
23222324
g.useLocalauth = find_option("localauth", 0, 0)!=0;
23232325
g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2326
+ g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
23242327
useSCGI = find_option("scgi", 0, 0)!=0;
23252328
zAltBase = find_option("baseurl", 0, 1);
23262329
if( zAltBase ) set_base_url(zAltBase);
23272330
if( find_option("https",0,0)!=0 ){
23282331
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
@@ -2409,10 +2412,11 @@
24092412
g.useLocalauth = 1;
24102413
g.httpIn = stdin;
24112414
g.httpOut = stdout;
24122415
find_server_repository(2, 0);
24132416
g.cgiOutput = 1;
2417
+ g.fNoHttpCompress = 1;
24142418
g.fullHttpReply = 1;
24152419
zIpAddr = cgi_ssh_remote_addr(0);
24162420
if( zIpAddr && zIpAddr[0] ){
24172421
g.fSshClient |= CGI_SSH_CLIENT;
24182422
ssh_request_loop(zIpAddr, 0);
@@ -2508,10 +2512,11 @@
25082512
** --localauth enable automatic login for requests from localhost
25092513
** --localhost listen on 127.0.0.1 only (always true for "ui")
25102514
** --https signal a request coming in via https
25112515
** --max-latency N Do not let any single HTTP request run for more than N
25122516
** seconds (only works on unix)
2517
+** --nocompress Do not compress HTTP replies
25132518
** --nojail Drop root privileges but do not enter the chroot jail
25142519
** --nossl signal that no SSL connections are available
25152520
** --notfound URL Redirect
25162521
** -P|--port TCPPORT listen to request on port TCPPORT
25172522
** --th-trace trace TH1 execution (for debugging purposes)
@@ -2573,10 +2578,11 @@
25732578
if( isUiCmd ){
25742579
zInitPage = find_option("page", 0, 1);
25752580
}
25762581
zNotFound = find_option("notfound", 0, 1);
25772582
allowRepoList = find_option("repolist",0,0)!=0;
2583
+ if( find_option("nocompress",0,0)!=0 ) g.fNoHttpCompress = 1;
25782584
zAltBase = find_option("baseurl", 0, 1);
25792585
fCreate = find_option("create",0,0)!=0;
25802586
if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
25812587
if( zAltBase ){
25822588
set_base_url(zAltBase);
25832589
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150 int fAnyTrace; /* Any kind of tracing */
151 char *zHttpAuth; /* HTTP Authorization user:pass information */
152 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
153 int fSshTrace; /* Trace the SSH setup traffic */
154 int fSshClient; /* HTTP client flags for SSH client */
 
155 char *zSshCmd; /* SSH command string */
156 int fNoSync; /* Do not do an autosync ever. --nosync */
157 int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */
158 char *zPath; /* Name of webpage being served */
159 char *zExtra; /* Extra path information past the webpage name */
@@ -2274,10 +2275,11 @@
2274 ** --baseurl URL base URL (useful with reverse proxies)
2275 ** --files GLOB comma-separate glob patterns for static file to serve
2276 ** --localauth enable automatic login for local connections
2277 ** --host NAME specify hostname of the server
2278 ** --https signal a request coming in via https
 
2279 ** --nojail drop root privilege but do not enter the chroot jail
2280 ** --nossl signal that no SSL connections are available
2281 ** --notfound URL use URL as "HTTP 404, object not found" page.
2282 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2283 ** --scgi Interpret input as SCGI rather than HTTP
@@ -2319,10 +2321,11 @@
2319 zNotFound = find_option("notfound", 0, 1);
2320 noJail = find_option("nojail",0,0)!=0;
2321 allowRepoList = find_option("repolist",0,0)!=0;
2322 g.useLocalauth = find_option("localauth", 0, 0)!=0;
2323 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
 
2324 useSCGI = find_option("scgi", 0, 0)!=0;
2325 zAltBase = find_option("baseurl", 0, 1);
2326 if( zAltBase ) set_base_url(zAltBase);
2327 if( find_option("https",0,0)!=0 ){
2328 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
@@ -2409,10 +2412,11 @@
2409 g.useLocalauth = 1;
2410 g.httpIn = stdin;
2411 g.httpOut = stdout;
2412 find_server_repository(2, 0);
2413 g.cgiOutput = 1;
 
2414 g.fullHttpReply = 1;
2415 zIpAddr = cgi_ssh_remote_addr(0);
2416 if( zIpAddr && zIpAddr[0] ){
2417 g.fSshClient |= CGI_SSH_CLIENT;
2418 ssh_request_loop(zIpAddr, 0);
@@ -2508,10 +2512,11 @@
2508 ** --localauth enable automatic login for requests from localhost
2509 ** --localhost listen on 127.0.0.1 only (always true for "ui")
2510 ** --https signal a request coming in via https
2511 ** --max-latency N Do not let any single HTTP request run for more than N
2512 ** seconds (only works on unix)
 
2513 ** --nojail Drop root privileges but do not enter the chroot jail
2514 ** --nossl signal that no SSL connections are available
2515 ** --notfound URL Redirect
2516 ** -P|--port TCPPORT listen to request on port TCPPORT
2517 ** --th-trace trace TH1 execution (for debugging purposes)
@@ -2573,10 +2578,11 @@
2573 if( isUiCmd ){
2574 zInitPage = find_option("page", 0, 1);
2575 }
2576 zNotFound = find_option("notfound", 0, 1);
2577 allowRepoList = find_option("repolist",0,0)!=0;
 
2578 zAltBase = find_option("baseurl", 0, 1);
2579 fCreate = find_option("create",0,0)!=0;
2580 if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
2581 if( zAltBase ){
2582 set_base_url(zAltBase);
2583
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150 int fAnyTrace; /* Any kind of tracing */
151 char *zHttpAuth; /* HTTP Authorization user:pass information */
152 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
153 int fSshTrace; /* Trace the SSH setup traffic */
154 int fSshClient; /* HTTP client flags for SSH client */
155 int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
156 char *zSshCmd; /* SSH command string */
157 int fNoSync; /* Do not do an autosync ever. --nosync */
158 int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */
159 char *zPath; /* Name of webpage being served */
160 char *zExtra; /* Extra path information past the webpage name */
@@ -2274,10 +2275,11 @@
2275 ** --baseurl URL base URL (useful with reverse proxies)
2276 ** --files GLOB comma-separate glob patterns for static file to serve
2277 ** --localauth enable automatic login for local connections
2278 ** --host NAME specify hostname of the server
2279 ** --https signal a request coming in via https
2280 ** --nocompress Do not compress HTTP replies
2281 ** --nojail drop root privilege but do not enter the chroot jail
2282 ** --nossl signal that no SSL connections are available
2283 ** --notfound URL use URL as "HTTP 404, object not found" page.
2284 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2285 ** --scgi Interpret input as SCGI rather than HTTP
@@ -2319,10 +2321,11 @@
2321 zNotFound = find_option("notfound", 0, 1);
2322 noJail = find_option("nojail",0,0)!=0;
2323 allowRepoList = find_option("repolist",0,0)!=0;
2324 g.useLocalauth = find_option("localauth", 0, 0)!=0;
2325 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2326 g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
2327 useSCGI = find_option("scgi", 0, 0)!=0;
2328 zAltBase = find_option("baseurl", 0, 1);
2329 if( zAltBase ) set_base_url(zAltBase);
2330 if( find_option("https",0,0)!=0 ){
2331 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
@@ -2409,10 +2412,11 @@
2412 g.useLocalauth = 1;
2413 g.httpIn = stdin;
2414 g.httpOut = stdout;
2415 find_server_repository(2, 0);
2416 g.cgiOutput = 1;
2417 g.fNoHttpCompress = 1;
2418 g.fullHttpReply = 1;
2419 zIpAddr = cgi_ssh_remote_addr(0);
2420 if( zIpAddr && zIpAddr[0] ){
2421 g.fSshClient |= CGI_SSH_CLIENT;
2422 ssh_request_loop(zIpAddr, 0);
@@ -2508,10 +2512,11 @@
2512 ** --localauth enable automatic login for requests from localhost
2513 ** --localhost listen on 127.0.0.1 only (always true for "ui")
2514 ** --https signal a request coming in via https
2515 ** --max-latency N Do not let any single HTTP request run for more than N
2516 ** seconds (only works on unix)
2517 ** --nocompress Do not compress HTTP replies
2518 ** --nojail Drop root privileges but do not enter the chroot jail
2519 ** --nossl signal that no SSL connections are available
2520 ** --notfound URL Redirect
2521 ** -P|--port TCPPORT listen to request on port TCPPORT
2522 ** --th-trace trace TH1 execution (for debugging purposes)
@@ -2573,10 +2578,11 @@
2578 if( isUiCmd ){
2579 zInitPage = find_option("page", 0, 1);
2580 }
2581 zNotFound = find_option("notfound", 0, 1);
2582 allowRepoList = find_option("repolist",0,0)!=0;
2583 if( find_option("nocompress",0,0)!=0 ) g.fNoHttpCompress = 1;
2584 zAltBase = find_option("baseurl", 0, 1);
2585 fCreate = find_option("create",0,0)!=0;
2586 if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
2587 if( zAltBase ){
2588 set_base_url(zAltBase);
2589
--- src/printf.c
+++ src/printf.c
@@ -1091,10 +1091,11 @@
10911091
#endif
10921092
{
10931093
if( g.cgiOutput==1 && g.db ){
10941094
g.cgiOutput = 2;
10951095
cgi_reset_content();
1096
+ cgi_set_content_type("text/html");
10961097
style_header("Bad Request");
10971098
@ <p class="generalError">%h(z)</p>
10981099
cgi_set_status(400, "Bad Request");
10991100
style_footer();
11001101
cgi_reply();
11011102
--- src/printf.c
+++ src/printf.c
@@ -1091,10 +1091,11 @@
1091 #endif
1092 {
1093 if( g.cgiOutput==1 && g.db ){
1094 g.cgiOutput = 2;
1095 cgi_reset_content();
 
1096 style_header("Bad Request");
1097 @ <p class="generalError">%h(z)</p>
1098 cgi_set_status(400, "Bad Request");
1099 style_footer();
1100 cgi_reply();
1101
--- src/printf.c
+++ src/printf.c
@@ -1091,10 +1091,11 @@
1091 #endif
1092 {
1093 if( g.cgiOutput==1 && g.db ){
1094 g.cgiOutput = 2;
1095 cgi_reset_content();
1096 cgi_set_content_type("text/html");
1097 style_header("Bad Request");
1098 @ <p class="generalError">%h(z)</p>
1099 cgi_set_status(400, "Bad Request");
1100 style_footer();
1101 cgi_reply();
1102

Keyboard Shortcuts

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