Fossil SCM

Enhance the test_env webpage so that it shows the original HTTP header text in showall=1 mode.

drh 2013-08-03 23:19 UTC trunk
Commit 03f07b5a664bcba4e76a1d06411d76e129413242
+3
--- src/cgi.c
+++ src/cgi.c
@@ -1185,10 +1185,12 @@
11851185
char zLine[2000]; /* A single line of input. */
11861186
g.fullHttpReply = 1;
11871187
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
11881188
malformed_request();
11891189
}
1190
+ blob_zero(&g.httpHeader);
1191
+ blob_append(&g.httpHeader, zLine, -1);
11901192
cgi_trace(zLine);
11911193
zToken = extract_token(zLine, &z);
11921194
if( zToken==0 ){
11931195
malformed_request();
11941196
}
@@ -1223,10 +1225,11 @@
12231225
while( fgets(zLine,sizeof(zLine),g.httpIn) ){
12241226
char *zFieldName;
12251227
char *zVal;
12261228
12271229
cgi_trace(zLine);
1230
+ blob_append(&g.httpHeader, zLine, -1);
12281231
zFieldName = extract_token(zLine,&zVal);
12291232
if( zFieldName==0 || *zFieldName==0 ) break;
12301233
while( fossil_isspace(*zVal) ){ zVal++; }
12311234
i = strlen(zVal);
12321235
while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
12331236
--- src/cgi.c
+++ src/cgi.c
@@ -1185,10 +1185,12 @@
1185 char zLine[2000]; /* A single line of input. */
1186 g.fullHttpReply = 1;
1187 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
1188 malformed_request();
1189 }
 
 
1190 cgi_trace(zLine);
1191 zToken = extract_token(zLine, &z);
1192 if( zToken==0 ){
1193 malformed_request();
1194 }
@@ -1223,10 +1225,11 @@
1223 while( fgets(zLine,sizeof(zLine),g.httpIn) ){
1224 char *zFieldName;
1225 char *zVal;
1226
1227 cgi_trace(zLine);
 
1228 zFieldName = extract_token(zLine,&zVal);
1229 if( zFieldName==0 || *zFieldName==0 ) break;
1230 while( fossil_isspace(*zVal) ){ zVal++; }
1231 i = strlen(zVal);
1232 while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
1233
--- src/cgi.c
+++ src/cgi.c
@@ -1185,10 +1185,12 @@
1185 char zLine[2000]; /* A single line of input. */
1186 g.fullHttpReply = 1;
1187 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
1188 malformed_request();
1189 }
1190 blob_zero(&g.httpHeader);
1191 blob_append(&g.httpHeader, zLine, -1);
1192 cgi_trace(zLine);
1193 zToken = extract_token(zLine, &z);
1194 if( zToken==0 ){
1195 malformed_request();
1196 }
@@ -1223,10 +1225,11 @@
1225 while( fgets(zLine,sizeof(zLine),g.httpIn) ){
1226 char *zFieldName;
1227 char *zVal;
1228
1229 cgi_trace(zLine);
1230 blob_append(&g.httpHeader, zLine, -1);
1231 zFieldName = extract_token(zLine,&zVal);
1232 if( zFieldName==0 || *zFieldName==0 ) break;
1233 while( fossil_isspace(*zVal) ){ zVal++; }
1234 i = strlen(zVal);
1235 while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
1236
+1
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159159
int markPrivate; /* All new artifacts are private if true */
160160
int clockSkewSeen; /* True if clocks on client and server out of sync */
161161
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162162
char isHTTP; /* True if server/CGI modes, else assume CLI. */
163163
char javascriptHyperlink; /* If true, set href= using script, not HTML */
164
+ Blob httpHeader; /* Complete text of the HTTP request header */
164165
165166
int urlIsFile; /* True if a "file:" url */
166167
int urlIsHttps; /* True if a "https:" url */
167168
int urlIsSsh; /* True if an "ssh:" url */
168169
char *urlName; /* Hostname for http: or filename for file: */
169170
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159 int markPrivate; /* All new artifacts are private if true */
160 int clockSkewSeen; /* True if clocks on client and server out of sync */
161 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162 char isHTTP; /* True if server/CGI modes, else assume CLI. */
163 char javascriptHyperlink; /* If true, set href= using script, not HTML */
 
164
165 int urlIsFile; /* True if a "file:" url */
166 int urlIsHttps; /* True if a "https:" url */
167 int urlIsSsh; /* True if an "ssh:" url */
168 char *urlName; /* Hostname for http: or filename for file: */
169
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159 int markPrivate; /* All new artifacts are private if true */
160 int clockSkewSeen; /* True if clocks on client and server out of sync */
161 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162 char isHTTP; /* True if server/CGI modes, else assume CLI. */
163 char javascriptHyperlink; /* If true, set href= using script, not HTML */
164 Blob httpHeader; /* Complete text of the HTTP request header */
165
166 int urlIsFile; /* True if a "file:" url */
167 int urlIsHttps; /* True if a "https:" url */
168 int urlIsSsh; /* True if an "ssh:" url */
169 char *urlName; /* Hostname for http: or filename for file: */
170
+7 -1
--- src/style.c
+++ src/style.c
@@ -1179,11 +1179,17 @@
11791179
@ g.userUid = %d(g.userUid)<br />
11801180
@ g.zLogin = %h(g.zLogin)<br />
11811181
@ capabilities = %s(zCap)<br />
11821182
@ <hr>
11831183
P("HTTP_USER_AGENT");
1184
- cgi_print_all(atoi(PD("showall","0")));
1184
+ cgi_print_all(showAll);
1185
+ if( showAll ){
1186
+ @ <hr>
1187
+ @ <pre>
1188
+ @ %h(blob_str(&g.httpHeader))
1189
+ @ </pre>
1190
+ }
11851191
if( g.perm.Setup ){
11861192
const char *zRedir = P("redirect");
11871193
if( zRedir ) cgi_redirect(zRedir);
11881194
}
11891195
style_footer();
11901196
--- src/style.c
+++ src/style.c
@@ -1179,11 +1179,17 @@
1179 @ g.userUid = %d(g.userUid)<br />
1180 @ g.zLogin = %h(g.zLogin)<br />
1181 @ capabilities = %s(zCap)<br />
1182 @ <hr>
1183 P("HTTP_USER_AGENT");
1184 cgi_print_all(atoi(PD("showall","0")));
 
 
 
 
 
 
1185 if( g.perm.Setup ){
1186 const char *zRedir = P("redirect");
1187 if( zRedir ) cgi_redirect(zRedir);
1188 }
1189 style_footer();
1190
--- src/style.c
+++ src/style.c
@@ -1179,11 +1179,17 @@
1179 @ g.userUid = %d(g.userUid)<br />
1180 @ g.zLogin = %h(g.zLogin)<br />
1181 @ capabilities = %s(zCap)<br />
1182 @ <hr>
1183 P("HTTP_USER_AGENT");
1184 cgi_print_all(showAll);
1185 if( showAll ){
1186 @ <hr>
1187 @ <pre>
1188 @ %h(blob_str(&g.httpHeader))
1189 @ </pre>
1190 }
1191 if( g.perm.Setup ){
1192 const char *zRedir = P("redirect");
1193 if( zRedir ) cgi_redirect(zRedir);
1194 }
1195 style_footer();
1196

Keyboard Shortcuts

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