Fossil SCM

Doc improvements and internal API renaming for clarity. No functional changes.

stephan 2025-07-24 02:20 xfer-login-card
Commit 286110dec0d1b95f82743768b5c7572ec7a20c651fa3d499f60bbdd3c7581cb2
3 files changed +5 -6 +8 -6 +11 -12
+5 -6
--- src/cgi.c
+++ src/cgi.c
@@ -1284,13 +1284,13 @@
12841284
/*
12851285
** Checks the QUERY_STRING environment variable, sets it up via
12861286
** add_param_list() and, if found, applies its "skin" setting. Returns
12871287
** 0 if no QUERY_STRING is set, else it returns a bitmask of:
12881288
**
1289
-** 0x01 = QUERY_STRING was set.
1290
-** 0x02 = "skin" argument was set and processed
1291
-** 0x04 = "x-f-x-l" arg was processed.
1289
+** 0x01 = QUERY_STRING was set up
1290
+** 0x02 = "skin" GET arg was processed
1291
+** 0x04 = "x-f-x-l" GET arg was processed.
12921292
**
12931293
* In the case of the skin, the cookie may still need flushing
12941294
** by the page, via cookie_render().
12951295
*/
12961296
int cgi_setup_query_string(void){
@@ -1318,11 +1318,11 @@
13181318
** they cannot see the X-Fossil-Xfer-Login card. As a consolation
13191319
** to them, we'll accept that via this query argument. */
13201320
rc |= 0x04;
13211321
fossil_free( g.syncInfo.zLoginCard );
13221322
g.syncInfo.zLoginCard = fossil_strdup(z);
1323
- g.syncInfo.bLoginCardHeader = 3;
1323
+ g.syncInfo.fLoginCardMode = 3;
13241324
cgi_delete_parameter("x-f-x-l");
13251325
}
13261326
}
13271327
return rc;
13281328
}
@@ -2141,11 +2141,10 @@
21412141
const char *zScheme = "http";
21422142
char zLine[2000]; /* A single line of input. */
21432143
g.fullHttpReply = 1;
21442144
g.zReqType = "HTTP";
21452145
2146
- /*cgi_setenv("JUST_TESTING1", "cgi_handle_http_request()");*/
21472146
if( cgi_fgets(zLine, sizeof(zLine))==0 ){
21482147
malformed_request("missing header");
21492148
}
21502149
blob_append(&g.httpHeader, zLine, -1);
21512150
cgi_trace(zLine);
@@ -2240,11 +2239,11 @@
22402239
rangeEnd = x2+1;
22412240
}
22422241
}else if( fossil_strcmp(zFieldName, "x-fossil-xfer-login:")==0 ){
22432242
fossil_free( g.syncInfo.zLoginCard );
22442243
g.syncInfo.zLoginCard = fossil_strdup(zVal);
2245
- g.syncInfo.bLoginCardHeader = 1;
2244
+ g.syncInfo.fLoginCardMode = 1;
22462245
}
22472246
}
22482247
cgi_setenv("REQUEST_SCHEME",zScheme);
22492248
cgi_init();
22502249
cgi_trace(0);
22512250
--- src/cgi.c
+++ src/cgi.c
@@ -1284,13 +1284,13 @@
1284 /*
1285 ** Checks the QUERY_STRING environment variable, sets it up via
1286 ** add_param_list() and, if found, applies its "skin" setting. Returns
1287 ** 0 if no QUERY_STRING is set, else it returns a bitmask of:
1288 **
1289 ** 0x01 = QUERY_STRING was set.
1290 ** 0x02 = "skin" argument was set and processed
1291 ** 0x04 = "x-f-x-l" arg was processed.
1292 **
1293 * In the case of the skin, the cookie may still need flushing
1294 ** by the page, via cookie_render().
1295 */
1296 int cgi_setup_query_string(void){
@@ -1318,11 +1318,11 @@
1318 ** they cannot see the X-Fossil-Xfer-Login card. As a consolation
1319 ** to them, we'll accept that via this query argument. */
1320 rc |= 0x04;
1321 fossil_free( g.syncInfo.zLoginCard );
1322 g.syncInfo.zLoginCard = fossil_strdup(z);
1323 g.syncInfo.bLoginCardHeader = 3;
1324 cgi_delete_parameter("x-f-x-l");
1325 }
1326 }
1327 return rc;
1328 }
@@ -2141,11 +2141,10 @@
2141 const char *zScheme = "http";
2142 char zLine[2000]; /* A single line of input. */
2143 g.fullHttpReply = 1;
2144 g.zReqType = "HTTP";
2145
2146 /*cgi_setenv("JUST_TESTING1", "cgi_handle_http_request()");*/
2147 if( cgi_fgets(zLine, sizeof(zLine))==0 ){
2148 malformed_request("missing header");
2149 }
2150 blob_append(&g.httpHeader, zLine, -1);
2151 cgi_trace(zLine);
@@ -2240,11 +2239,11 @@
2240 rangeEnd = x2+1;
2241 }
2242 }else if( fossil_strcmp(zFieldName, "x-fossil-xfer-login:")==0 ){
2243 fossil_free( g.syncInfo.zLoginCard );
2244 g.syncInfo.zLoginCard = fossil_strdup(zVal);
2245 g.syncInfo.bLoginCardHeader = 1;
2246 }
2247 }
2248 cgi_setenv("REQUEST_SCHEME",zScheme);
2249 cgi_init();
2250 cgi_trace(0);
2251
--- src/cgi.c
+++ src/cgi.c
@@ -1284,13 +1284,13 @@
1284 /*
1285 ** Checks the QUERY_STRING environment variable, sets it up via
1286 ** add_param_list() and, if found, applies its "skin" setting. Returns
1287 ** 0 if no QUERY_STRING is set, else it returns a bitmask of:
1288 **
1289 ** 0x01 = QUERY_STRING was set up
1290 ** 0x02 = "skin" GET arg was processed
1291 ** 0x04 = "x-f-x-l" GET arg was processed.
1292 **
1293 * In the case of the skin, the cookie may still need flushing
1294 ** by the page, via cookie_render().
1295 */
1296 int cgi_setup_query_string(void){
@@ -1318,11 +1318,11 @@
1318 ** they cannot see the X-Fossil-Xfer-Login card. As a consolation
1319 ** to them, we'll accept that via this query argument. */
1320 rc |= 0x04;
1321 fossil_free( g.syncInfo.zLoginCard );
1322 g.syncInfo.zLoginCard = fossil_strdup(z);
1323 g.syncInfo.fLoginCardMode = 3;
1324 cgi_delete_parameter("x-f-x-l");
1325 }
1326 }
1327 return rc;
1328 }
@@ -2141,11 +2141,10 @@
2141 const char *zScheme = "http";
2142 char zLine[2000]; /* A single line of input. */
2143 g.fullHttpReply = 1;
2144 g.zReqType = "HTTP";
2145
 
2146 if( cgi_fgets(zLine, sizeof(zLine))==0 ){
2147 malformed_request("missing header");
2148 }
2149 blob_append(&g.httpHeader, zLine, -1);
2150 cgi_trace(zLine);
@@ -2240,11 +2239,11 @@
2239 rangeEnd = x2+1;
2240 }
2241 }else if( fossil_strcmp(zFieldName, "x-fossil-xfer-login:")==0 ){
2242 fossil_free( g.syncInfo.zLoginCard );
2243 g.syncInfo.zLoginCard = fossil_strdup(zVal);
2244 g.syncInfo.fLoginCardMode = 1;
2245 }
2246 }
2247 cgi_setenv("REQUEST_SCHEME",zScheme);
2248 cgi_init();
2249 cgi_trace(0);
2250
+8 -6
--- src/http.c
+++ src/http.c
@@ -137,22 +137,22 @@
137137
** login card to CGI-hosted fossil instances, as those do not read the
138138
** HTTP headers so cannot see the X-Fossil-Xfer-Login (x-f-x-l)
139139
** header.
140140
*/
141141
static void url_append_login_card(Blob * const pLogin){
142
- if( g.syncInfo.bLoginCardHeader ||
142
+ if( g.syncInfo.fLoginCardMode ||
143143
g.syncInfo.remoteVersion >= RELEASE_VERSION_NUMBER ){
144144
char * x;
145145
char * z = g.url.path;
146146
while( z && *z && '?'!=*z ) ++z;
147147
if( z && *z ) *z = 0;
148148
x = mprintf("%s?x-f-x-l=%T", g.url.path ? g.url.path : "/",
149149
blob_str(pLogin));
150150
fossil_free(g.url.path);
151151
g.url.path = x;
152
- if( !g.syncInfo.bLoginCardHeader ){
153
- g.syncInfo.bLoginCardHeader = 4;
152
+ if( !g.syncInfo.fLoginCardMode ){
153
+ g.syncInfo.fLoginCardMode = 4;
154154
}
155155
}
156156
}
157157
158158
/*
@@ -189,11 +189,13 @@
189189
blob_appendf(pHdr, "Host: %s\r\n", g.url.hostname);
190190
blob_appendf(pHdr, "User-Agent: %s\r\n", get_user_agent());
191191
if( g.url.isSsh ) blob_appendf(pHdr, "X-Fossil-Transport: SSH\r\n");
192192
if( pLogin && blob_size(pLogin) ){
193193
blob_appendf(pHdr, "X-Fossil-Xfer-Login: %b\r\n", pLogin)
194
- /* Noting that CGIs can't read headers */;
194
+ /* Noting that CGIs can't read headers, but test-http can. If we
195
+ ** set this _only_ as a URL argument then we lose that info for
196
+ ** purposes of feeding it back through test-http. */;
195197
}
196198
if( nPayload ){
197199
if( zAltMimetype ){
198200
blob_appendf(pHdr, "Content-Type: %s\r\n", zAltMimetype);
199201
}else if( g.fHttpTrace ){
@@ -501,11 +503,11 @@
501503
blob_zero(&login);
502504
if( blob_size(pSend)==0 ){
503505
blob_zero(&payload);
504506
}else{
505507
if( mHttpFlags & HTTP_USE_LOGIN ) http_build_login_card(pSend, &login);
506
- if( g.syncInfo.bLoginCardHeader>0 ){
508
+ if( g.syncInfo.fLoginCardMode>0 ){
507509
/* The login card will be sent via an HTTP header and/or URL flag. */
508510
if( g.fHttpTrace || (mHttpFlags & HTTP_NOCOMPRESS)!=0 ){
509511
/* Maintenance note: we cannot blob_swap(pSend,&payload) here
510512
** because the HTTP 401 and redirect response handling below
511513
** needs pSend unmodified. payload won't be modified after
@@ -694,11 +696,11 @@
694696
}
695697
}
696698
}else if( fossil_strnicmp(zLine, "x-fossil-xfer-login: ", 21)==0 ){
697699
fossil_free( g.syncInfo.zLoginCard );
698700
g.syncInfo.zLoginCard = fossil_strdup(&zLine[21]);
699
- g.syncInfo.bLoginCardHeader = 1;
701
+ g.syncInfo.fLoginCardMode = 1;
700702
}
701703
}
702704
if( iHttpVersion<0 ){
703705
/* We got nothing back from the server. If using the ssh: protocol,
704706
** this might mean we need to add or remove the PATH=... argument
705707
--- src/http.c
+++ src/http.c
@@ -137,22 +137,22 @@
137 ** login card to CGI-hosted fossil instances, as those do not read the
138 ** HTTP headers so cannot see the X-Fossil-Xfer-Login (x-f-x-l)
139 ** header.
140 */
141 static void url_append_login_card(Blob * const pLogin){
142 if( g.syncInfo.bLoginCardHeader ||
143 g.syncInfo.remoteVersion >= RELEASE_VERSION_NUMBER ){
144 char * x;
145 char * z = g.url.path;
146 while( z && *z && '?'!=*z ) ++z;
147 if( z && *z ) *z = 0;
148 x = mprintf("%s?x-f-x-l=%T", g.url.path ? g.url.path : "/",
149 blob_str(pLogin));
150 fossil_free(g.url.path);
151 g.url.path = x;
152 if( !g.syncInfo.bLoginCardHeader ){
153 g.syncInfo.bLoginCardHeader = 4;
154 }
155 }
156 }
157
158 /*
@@ -189,11 +189,13 @@
189 blob_appendf(pHdr, "Host: %s\r\n", g.url.hostname);
190 blob_appendf(pHdr, "User-Agent: %s\r\n", get_user_agent());
191 if( g.url.isSsh ) blob_appendf(pHdr, "X-Fossil-Transport: SSH\r\n");
192 if( pLogin && blob_size(pLogin) ){
193 blob_appendf(pHdr, "X-Fossil-Xfer-Login: %b\r\n", pLogin)
194 /* Noting that CGIs can't read headers */;
 
 
195 }
196 if( nPayload ){
197 if( zAltMimetype ){
198 blob_appendf(pHdr, "Content-Type: %s\r\n", zAltMimetype);
199 }else if( g.fHttpTrace ){
@@ -501,11 +503,11 @@
501 blob_zero(&login);
502 if( blob_size(pSend)==0 ){
503 blob_zero(&payload);
504 }else{
505 if( mHttpFlags & HTTP_USE_LOGIN ) http_build_login_card(pSend, &login);
506 if( g.syncInfo.bLoginCardHeader>0 ){
507 /* The login card will be sent via an HTTP header and/or URL flag. */
508 if( g.fHttpTrace || (mHttpFlags & HTTP_NOCOMPRESS)!=0 ){
509 /* Maintenance note: we cannot blob_swap(pSend,&payload) here
510 ** because the HTTP 401 and redirect response handling below
511 ** needs pSend unmodified. payload won't be modified after
@@ -694,11 +696,11 @@
694 }
695 }
696 }else if( fossil_strnicmp(zLine, "x-fossil-xfer-login: ", 21)==0 ){
697 fossil_free( g.syncInfo.zLoginCard );
698 g.syncInfo.zLoginCard = fossil_strdup(&zLine[21]);
699 g.syncInfo.bLoginCardHeader = 1;
700 }
701 }
702 if( iHttpVersion<0 ){
703 /* We got nothing back from the server. If using the ssh: protocol,
704 ** this might mean we need to add or remove the PATH=... argument
705
--- src/http.c
+++ src/http.c
@@ -137,22 +137,22 @@
137 ** login card to CGI-hosted fossil instances, as those do not read the
138 ** HTTP headers so cannot see the X-Fossil-Xfer-Login (x-f-x-l)
139 ** header.
140 */
141 static void url_append_login_card(Blob * const pLogin){
142 if( g.syncInfo.fLoginCardMode ||
143 g.syncInfo.remoteVersion >= RELEASE_VERSION_NUMBER ){
144 char * x;
145 char * z = g.url.path;
146 while( z && *z && '?'!=*z ) ++z;
147 if( z && *z ) *z = 0;
148 x = mprintf("%s?x-f-x-l=%T", g.url.path ? g.url.path : "/",
149 blob_str(pLogin));
150 fossil_free(g.url.path);
151 g.url.path = x;
152 if( !g.syncInfo.fLoginCardMode ){
153 g.syncInfo.fLoginCardMode = 4;
154 }
155 }
156 }
157
158 /*
@@ -189,11 +189,13 @@
189 blob_appendf(pHdr, "Host: %s\r\n", g.url.hostname);
190 blob_appendf(pHdr, "User-Agent: %s\r\n", get_user_agent());
191 if( g.url.isSsh ) blob_appendf(pHdr, "X-Fossil-Transport: SSH\r\n");
192 if( pLogin && blob_size(pLogin) ){
193 blob_appendf(pHdr, "X-Fossil-Xfer-Login: %b\r\n", pLogin)
194 /* Noting that CGIs can't read headers, but test-http can. If we
195 ** set this _only_ as a URL argument then we lose that info for
196 ** purposes of feeding it back through test-http. */;
197 }
198 if( nPayload ){
199 if( zAltMimetype ){
200 blob_appendf(pHdr, "Content-Type: %s\r\n", zAltMimetype);
201 }else if( g.fHttpTrace ){
@@ -501,11 +503,11 @@
503 blob_zero(&login);
504 if( blob_size(pSend)==0 ){
505 blob_zero(&payload);
506 }else{
507 if( mHttpFlags & HTTP_USE_LOGIN ) http_build_login_card(pSend, &login);
508 if( g.syncInfo.fLoginCardMode>0 ){
509 /* The login card will be sent via an HTTP header and/or URL flag. */
510 if( g.fHttpTrace || (mHttpFlags & HTTP_NOCOMPRESS)!=0 ){
511 /* Maintenance note: we cannot blob_swap(pSend,&payload) here
512 ** because the HTTP 401 and redirect response handling below
513 ** needs pSend unmodified. payload won't be modified after
@@ -694,11 +696,11 @@
696 }
697 }
698 }else if( fossil_strnicmp(zLine, "x-fossil-xfer-login: ", 21)==0 ){
699 fossil_free( g.syncInfo.zLoginCard );
700 g.syncInfo.zLoginCard = fossil_strdup(&zLine[21]);
701 g.syncInfo.fLoginCardMode = 1;
702 }
703 }
704 if( iHttpVersion<0 ){
705 /* We got nothing back from the server. If using the ssh: protocol,
706 ** this might mean we need to add or remove the PATH=... argument
707
+11 -12
--- src/main.c
+++ src/main.c
@@ -292,21 +292,20 @@
292292
int bAvoidDeltaManifests; /* Avoid using delta manifests if true */
293293
294294
/* State for communicating specific details between the inbound HTTP
295295
** header parser (cgi.c), xfer.c, and http.c. */
296296
struct {
297
- char *zLoginCard; /* Inbound X-Fossil-Xfer-Login request header
298
- ** or x-f-x-l URL parameter. */
299
- int bLoginCardHeader; /* If non-0, emit login cards in outbound
300
- ** requests as HTTP headers instead of as
301
- ** part of the payload. Gets activated
302
- ** on-demand based on xfer traffic
303
- ** contents. Values, for
304
- ** diagnostic/debuggin purposes: 1=set via
305
- ** CLI --flag. 2=set via inbound HTTP
306
- ** header. 3=set via query string
307
- ** arg. 4=set via http_build_header(). */
297
+ char *zLoginCard; /* Inbound "X-Fossil-Xfer-Login" request
298
+ ** header or "x-f-x-l" URL parameter. */
299
+ int fLoginCardMode; /* If non-0, emit login cards in outbound
300
+ ** requests as a HTTP header or URL
301
+ ** parameter instead of as part of the
302
+ ** payload. Gets activated on-demand based
303
+ ** on xfer traffic contents. Values, for
304
+ ** diagnostic/debugging purposes: 1=CLI
305
+ ** --flag. 2=inbound HTTP header. 3=query
306
+ ** string arg. 4=http_build_header(). */
308307
int remoteVersion; /* Remote fossil version. Used for negotiating
309308
** how to handle the login card. */
310309
} syncInfo;
311310
#ifdef FOSSIL_ENABLE_JSON
312311
struct FossilJsonBits {
@@ -776,11 +775,11 @@
776775
g.tcl.argc = g.argc;
777776
g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
778777
#endif
779778
g.mainTimerId = fossil_timer_start();
780779
capture_case_sensitive_option();
781
- g.syncInfo.bLoginCardHeader =
780
+ g.syncInfo.fLoginCardMode =
782781
/* This is only for facilitating development of the
783782
** xfer-login-card branch. It will be removed or re-imagined at
784783
** some point. */
785784
!!find_option("login-card-header","lch", 0);
786785
g.zVfsName = find_option("vfs",0,1);
787786
--- src/main.c
+++ src/main.c
@@ -292,21 +292,20 @@
292 int bAvoidDeltaManifests; /* Avoid using delta manifests if true */
293
294 /* State for communicating specific details between the inbound HTTP
295 ** header parser (cgi.c), xfer.c, and http.c. */
296 struct {
297 char *zLoginCard; /* Inbound X-Fossil-Xfer-Login request header
298 ** or x-f-x-l URL parameter. */
299 int bLoginCardHeader; /* If non-0, emit login cards in outbound
300 ** requests as HTTP headers instead of as
301 ** part of the payload. Gets activated
302 ** on-demand based on xfer traffic
303 ** contents. Values, for
304 ** diagnostic/debuggin purposes: 1=set via
305 ** CLI --flag. 2=set via inbound HTTP
306 ** header. 3=set via query string
307 ** arg. 4=set via http_build_header(). */
308 int remoteVersion; /* Remote fossil version. Used for negotiating
309 ** how to handle the login card. */
310 } syncInfo;
311 #ifdef FOSSIL_ENABLE_JSON
312 struct FossilJsonBits {
@@ -776,11 +775,11 @@
776 g.tcl.argc = g.argc;
777 g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
778 #endif
779 g.mainTimerId = fossil_timer_start();
780 capture_case_sensitive_option();
781 g.syncInfo.bLoginCardHeader =
782 /* This is only for facilitating development of the
783 ** xfer-login-card branch. It will be removed or re-imagined at
784 ** some point. */
785 !!find_option("login-card-header","lch", 0);
786 g.zVfsName = find_option("vfs",0,1);
787
--- src/main.c
+++ src/main.c
@@ -292,21 +292,20 @@
292 int bAvoidDeltaManifests; /* Avoid using delta manifests if true */
293
294 /* State for communicating specific details between the inbound HTTP
295 ** header parser (cgi.c), xfer.c, and http.c. */
296 struct {
297 char *zLoginCard; /* Inbound "X-Fossil-Xfer-Login" request
298 ** header or "x-f-x-l" URL parameter. */
299 int fLoginCardMode; /* If non-0, emit login cards in outbound
300 ** requests as a HTTP header or URL
301 ** parameter instead of as part of the
302 ** payload. Gets activated on-demand based
303 ** on xfer traffic contents. Values, for
304 ** diagnostic/debugging purposes: 1=CLI
305 ** --flag. 2=inbound HTTP header. 3=query
306 ** string arg. 4=http_build_header(). */
 
307 int remoteVersion; /* Remote fossil version. Used for negotiating
308 ** how to handle the login card. */
309 } syncInfo;
310 #ifdef FOSSIL_ENABLE_JSON
311 struct FossilJsonBits {
@@ -776,11 +775,11 @@
775 g.tcl.argc = g.argc;
776 g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
777 #endif
778 g.mainTimerId = fossil_timer_start();
779 capture_case_sensitive_option();
780 g.syncInfo.fLoginCardMode =
781 /* This is only for facilitating development of the
782 ** xfer-login-card branch. It will be removed or re-imagined at
783 ** some point. */
784 !!find_option("login-card-header","lch", 0);
785 g.zVfsName = find_option("vfs",0,1);
786

Keyboard Shortcuts

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