Fossil SCM

Fix a bug that preventing a redirect on sync from remembering the new URL. [forum:/forumpost/ea4b2ec3fe577e79|Forum post ea4b2ec3].

drh 2025-03-21 14:15 trunk
Commit 754e2c1b6e8e56a5cadee8f779dc05c5f6ca932280dcc7bb53c13c5d348341df
1 file changed +6 -1
+6 -1
--- src/http.c
+++ src/http.c
@@ -575,10 +575,11 @@
575575
}
576576
}else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
577577
fossil_strnicmp(zLine, "location:", 9)==0 ){
578578
int i, j;
579579
int wasHttps;
580
+ int priorUrlFlags;
580581
581582
if ( --maxRedirect == 0){
582583
fossil_warning("redirect limit exceeded");
583584
goto write_err;
584585
}
@@ -599,10 +600,11 @@
599600
fossil_warning("cannot redirect from %s to %s", g.url.canonical,
600601
&zLine[i]);
601602
goto write_err;
602603
}
603604
wasHttps = g.url.isHttps;
605
+ priorUrlFlags = g.url.flags;
604606
url_parse(&zLine[i], 0);
605607
if( wasHttps && !g.url.isHttps ){
606608
fossil_warning("cannot redirect from HTTPS to HTTP");
607609
goto write_err;
608610
}
@@ -613,11 +615,14 @@
613615
transport_close(&g.url);
614616
transport_global_shutdown(&g.url);
615617
fSeenHttpAuth = 0;
616618
if( g.zHttpAuth ) free(g.zHttpAuth);
617619
g.zHttpAuth = get_httpauth();
618
- if( rc==301 || rc==308 ) url_remember();
620
+ if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
621
+ g.url.flags |= URL_REMEMBER;
622
+ url_remember();
623
+ }
619624
return http_exchange(pSend, pReply, mHttpFlags,
620625
maxRedirect, zAltMimetype);
621626
}else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
622627
if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
623628
isCompressed = 0;
624629
--- src/http.c
+++ src/http.c
@@ -575,10 +575,11 @@
575 }
576 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
577 fossil_strnicmp(zLine, "location:", 9)==0 ){
578 int i, j;
579 int wasHttps;
 
580
581 if ( --maxRedirect == 0){
582 fossil_warning("redirect limit exceeded");
583 goto write_err;
584 }
@@ -599,10 +600,11 @@
599 fossil_warning("cannot redirect from %s to %s", g.url.canonical,
600 &zLine[i]);
601 goto write_err;
602 }
603 wasHttps = g.url.isHttps;
 
604 url_parse(&zLine[i], 0);
605 if( wasHttps && !g.url.isHttps ){
606 fossil_warning("cannot redirect from HTTPS to HTTP");
607 goto write_err;
608 }
@@ -613,11 +615,14 @@
613 transport_close(&g.url);
614 transport_global_shutdown(&g.url);
615 fSeenHttpAuth = 0;
616 if( g.zHttpAuth ) free(g.zHttpAuth);
617 g.zHttpAuth = get_httpauth();
618 if( rc==301 || rc==308 ) url_remember();
 
 
 
619 return http_exchange(pSend, pReply, mHttpFlags,
620 maxRedirect, zAltMimetype);
621 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
622 if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
623 isCompressed = 0;
624
--- src/http.c
+++ src/http.c
@@ -575,10 +575,11 @@
575 }
576 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
577 fossil_strnicmp(zLine, "location:", 9)==0 ){
578 int i, j;
579 int wasHttps;
580 int priorUrlFlags;
581
582 if ( --maxRedirect == 0){
583 fossil_warning("redirect limit exceeded");
584 goto write_err;
585 }
@@ -599,10 +600,11 @@
600 fossil_warning("cannot redirect from %s to %s", g.url.canonical,
601 &zLine[i]);
602 goto write_err;
603 }
604 wasHttps = g.url.isHttps;
605 priorUrlFlags = g.url.flags;
606 url_parse(&zLine[i], 0);
607 if( wasHttps && !g.url.isHttps ){
608 fossil_warning("cannot redirect from HTTPS to HTTP");
609 goto write_err;
610 }
@@ -613,11 +615,14 @@
615 transport_close(&g.url);
616 transport_global_shutdown(&g.url);
617 fSeenHttpAuth = 0;
618 if( g.zHttpAuth ) free(g.zHttpAuth);
619 g.zHttpAuth = get_httpauth();
620 if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
621 g.url.flags |= URL_REMEMBER;
622 url_remember();
623 }
624 return http_exchange(pSend, pReply, mHttpFlags,
625 maxRedirect, zAltMimetype);
626 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
627 if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
628 isCompressed = 0;
629

Keyboard Shortcuts

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