Fossil SCM

Adds the Apache-style REQUEST_SCHEME environment variable to the /ext environment so that CGIs can determine whether they're running in HTTP or HTTPS.

stephan 2020-12-12 08:15 trunk
Commit 0d72caae1592769e00ad0752757449c51a37a5a6dcac9b84a378e9b8ef744808
--- src/extcgi.c
+++ src/extcgi.c
@@ -67,10 +67,12 @@
6767
"PATH_INFO",
6868
"QUERY_STRING",
6969
"REMOTE_ADDR",
7070
"REMOTE_USER",
7171
"REQUEST_METHOD",
72
+ "REQUEST_SCHEME", /* non-standard but supported by Apache 2.4+
73
+ ** Holds either "http" or "https". */
7274
"REQUEST_URI",
7375
"SCRIPT_DIRECTORY",
7476
"SCRIPT_FILENAME",
7577
"SCRIPT_NAME",
7678
"SERVER_NAME",
@@ -266,10 +268,13 @@
266268
cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
267269
cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
268270
db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
269271
g.zLogin ? g.zLogin : "nobody"), 0);
270272
cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
273
+ cgi_replace_parameter("REQUEST_SCHEME",
274
+ strncmp(g.zTop, "https:", 6)==0
275
+ ? "https" : "http");
271276
for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
272277
(void)P(azCgiEnv[i]);
273278
}
274279
fossil_clearenv();
275280
for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
276281
--- src/extcgi.c
+++ src/extcgi.c
@@ -67,10 +67,12 @@
67 "PATH_INFO",
68 "QUERY_STRING",
69 "REMOTE_ADDR",
70 "REMOTE_USER",
71 "REQUEST_METHOD",
 
 
72 "REQUEST_URI",
73 "SCRIPT_DIRECTORY",
74 "SCRIPT_FILENAME",
75 "SCRIPT_NAME",
76 "SERVER_NAME",
@@ -266,10 +268,13 @@
266 cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
267 cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
268 db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
269 g.zLogin ? g.zLogin : "nobody"), 0);
270 cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
 
 
 
271 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
272 (void)P(azCgiEnv[i]);
273 }
274 fossil_clearenv();
275 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
276
--- src/extcgi.c
+++ src/extcgi.c
@@ -67,10 +67,12 @@
67 "PATH_INFO",
68 "QUERY_STRING",
69 "REMOTE_ADDR",
70 "REMOTE_USER",
71 "REQUEST_METHOD",
72 "REQUEST_SCHEME", /* non-standard but supported by Apache 2.4+
73 ** Holds either "http" or "https". */
74 "REQUEST_URI",
75 "SCRIPT_DIRECTORY",
76 "SCRIPT_FILENAME",
77 "SCRIPT_NAME",
78 "SERVER_NAME",
@@ -266,10 +268,13 @@
268 cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
269 cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
270 db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
271 g.zLogin ? g.zLogin : "nobody"), 0);
272 cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
273 cgi_replace_parameter("REQUEST_SCHEME",
274 strncmp(g.zTop, "https:", 6)==0
275 ? "https" : "http");
276 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
277 (void)P(azCgiEnv[i]);
278 }
279 fossil_clearenv();
280 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
281
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -168,10 +168,11 @@
168168
* FOSSIL_CAPABILITIES
169169
* FOSSIL_NONCE
170170
* FOSSIL_REPOSITORY
171171
* FOSSIL_URI
172172
* FOSSIL_USER
173
+ * REQUEST_SCHEME (as used by Apache: "http" or "https")
173174
174175
The FOSSIL_USER string is the name of the logged-in user. This variable
175176
is missing or is an empty string if the user is not logged in. The
176177
FOSSIL_CAPABILITIES string is a list of
177178
[./caps/ref.html|Fossil capabilities] that
178179
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -168,10 +168,11 @@
168 * FOSSIL_CAPABILITIES
169 * FOSSIL_NONCE
170 * FOSSIL_REPOSITORY
171 * FOSSIL_URI
172 * FOSSIL_USER
 
173
174 The FOSSIL_USER string is the name of the logged-in user. This variable
175 is missing or is an empty string if the user is not logged in. The
176 FOSSIL_CAPABILITIES string is a list of
177 [./caps/ref.html|Fossil capabilities] that
178
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -168,10 +168,11 @@
168 * FOSSIL_CAPABILITIES
169 * FOSSIL_NONCE
170 * FOSSIL_REPOSITORY
171 * FOSSIL_URI
172 * FOSSIL_USER
173 * REQUEST_SCHEME (as used by Apache: "http" or "https")
174
175 The FOSSIL_USER string is the name of the logged-in user. This variable
176 is missing or is an empty string if the user is not logged in. The
177 FOSSIL_CAPABILITIES string is a list of
178 [./caps/ref.html|Fossil capabilities] that
179

Keyboard Shortcuts

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