Fossil SCM
Fix the sync logic so that it is able to clone against the canonical fossil repository with its implied redirect.
Commit
a921be7b51aed1926c22a0562c57763be86857cb
Parent
9dd6c43185d68d6…
1 file changed
+5
-2
+5
-2
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -103,11 +103,11 @@ | ||
| 103 | 103 | if( i>0 && g.urlPath[i-1]=='/' ){ |
| 104 | 104 | zSep = ""; |
| 105 | 105 | }else{ |
| 106 | 106 | zSep = "/"; |
| 107 | 107 | } |
| 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); | |
| 109 | 109 | if( g.urlProxyAuth ){ |
| 110 | 110 | blob_appendf(pHdr, "Proxy-Authorization: %s\n", g.urlProxyAuth); |
| 111 | 111 | } |
| 112 | 112 | blob_appendf(pHdr, "Host: %s\r\n", g.urlHostname); |
| 113 | 113 | blob_appendf(pHdr, "User-Agent: Fossil/" MANIFEST_VERSION "\r\n"); |
| @@ -226,11 +226,14 @@ | ||
| 226 | 226 | }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){ |
| 227 | 227 | int i, j; |
| 228 | 228 | for(i=9; zLine[i] && zLine[i]==' '; i++){} |
| 229 | 229 | if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine); |
| 230 | 230 | 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 | + } | |
| 232 | 235 | fossil_print("redirect to %s\n", &zLine[i]); |
| 233 | 236 | url_parse(&zLine[i]); |
| 234 | 237 | transport_close(); |
| 235 | 238 | http_exchange(pSend, pReply, useLogin); |
| 236 | 239 | return; |
| 237 | 240 |
| --- 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 |