Fossil SCM

Fix the sync logic so that it is able to clone against the canonical fossil repository with its implied redirect.

drh 2010-11-06 14:04 UTC trunk
Commit a921be7b51aed1926c22a0562c57763be86857cb
1 file changed +5 -2
+5 -2
--- src/http.c
+++ src/http.c
@@ -103,11 +103,11 @@
103103
if( i>0 && g.urlPath[i-1]=='/' ){
104104
zSep = "";
105105
}else{
106106
zSep = "/";
107107
}
108
- blob_appendf(pHdr, "POST %s%sxfer HTTP/1.0\r\n", g.urlPath, zSep);
108
+ blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
109109
if( g.urlProxyAuth ){
110110
blob_appendf(pHdr, "Proxy-Authorization: %s\n", g.urlProxyAuth);
111111
}
112112
blob_appendf(pHdr, "Host: %s\r\n", g.urlHostname);
113113
blob_appendf(pHdr, "User-Agent: Fossil/" MANIFEST_VERSION "\r\n");
@@ -226,11 +226,14 @@
226226
}else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
227227
int i, j;
228228
for(i=9; zLine[i] && zLine[i]==' '; i++){}
229229
if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
230230
j = strlen(zLine) - 1;
231
- if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
231
+ while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){
232
+ j -= 4;
233
+ zLine[j] = 0;
234
+ }
232235
fossil_print("redirect to %s\n", &zLine[i]);
233236
url_parse(&zLine[i]);
234237
transport_close();
235238
http_exchange(pSend, pReply, useLogin);
236239
return;
237240
--- src/http.c
+++ src/http.c
@@ -103,11 +103,11 @@
103 if( i>0 && g.urlPath[i-1]=='/' ){
104 zSep = "";
105 }else{
106 zSep = "/";
107 }
108 blob_appendf(pHdr, "POST %s%sxfer HTTP/1.0\r\n", g.urlPath, zSep);
109 if( g.urlProxyAuth ){
110 blob_appendf(pHdr, "Proxy-Authorization: %s\n", g.urlProxyAuth);
111 }
112 blob_appendf(pHdr, "Host: %s\r\n", g.urlHostname);
113 blob_appendf(pHdr, "User-Agent: Fossil/" MANIFEST_VERSION "\r\n");
@@ -226,11 +226,14 @@
226 }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
227 int i, j;
228 for(i=9; zLine[i] && zLine[i]==' '; i++){}
229 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
230 j = strlen(zLine) - 1;
231 if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
 
 
 
232 fossil_print("redirect to %s\n", &zLine[i]);
233 url_parse(&zLine[i]);
234 transport_close();
235 http_exchange(pSend, pReply, useLogin);
236 return;
237
--- src/http.c
+++ src/http.c
@@ -103,11 +103,11 @@
103 if( i>0 && g.urlPath[i-1]=='/' ){
104 zSep = "";
105 }else{
106 zSep = "/";
107 }
108 blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
109 if( g.urlProxyAuth ){
110 blob_appendf(pHdr, "Proxy-Authorization: %s\n", g.urlProxyAuth);
111 }
112 blob_appendf(pHdr, "Host: %s\r\n", g.urlHostname);
113 blob_appendf(pHdr, "User-Agent: Fossil/" MANIFEST_VERSION "\r\n");
@@ -226,11 +226,14 @@
226 }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
227 int i, j;
228 for(i=9; zLine[i] && zLine[i]==' '; i++){}
229 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
230 j = strlen(zLine) - 1;
231 while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){
232 j -= 4;
233 zLine[j] = 0;
234 }
235 fossil_print("redirect to %s\n", &zLine[i]);
236 url_parse(&zLine[i]);
237 transport_close();
238 http_exchange(pSend, pReply, useLogin);
239 return;
240

Keyboard Shortcuts

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