Fossil SCM
This does not need to be globally scoped.
Commit
6315fd8a3d88641953ef2dbfb49e7bdc47457302
Parent
08d487ed732e4db…
2 files changed
+7
-2
-2
+7
-2
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -76,10 +76,15 @@ | ||
| 76 | 76 | blob_reset(&pw); |
| 77 | 77 | blob_reset(&sig); |
| 78 | 78 | blob_reset(&nonce); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | +/* | |
| 82 | +** Use HTTP Basic Authorization if a 401 is seen. | |
| 83 | +*/ | |
| 84 | +static int fUseHttpAuth = 0; | |
| 85 | + | |
| 81 | 86 | /* |
| 82 | 87 | ** Construct an appropriate HTTP request header. Write the header |
| 83 | 88 | ** into pHdr. This routine initializes the pHdr blob. pPayload is |
| 84 | 89 | ** the complete payload (including the login card) already compressed. |
| 85 | 90 | */ |
| @@ -96,11 +101,11 @@ | ||
| 96 | 101 | } |
| 97 | 102 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 98 | 103 | if( g.urlProxyAuth ){ |
| 99 | 104 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 100 | 105 | } |
| 101 | - if( g.urlPasswd && g.urlUser && g.fUseHttpAuth ){ | |
| 106 | + if( g.urlPasswd && g.urlUser && fUseHttpAuth ){ | |
| 102 | 107 | char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd); |
| 103 | 108 | char *zEncoded = encode64(zCredentials, -1); |
| 104 | 109 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 105 | 110 | fossil_free(zEncoded); |
| 106 | 111 | fossil_free(zCredentials); |
| @@ -200,11 +205,11 @@ | ||
| 200 | 205 | while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){ |
| 201 | 206 | /* printf("[%s]\n", zLine); fflush(stdout); */ |
| 202 | 207 | if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){ |
| 203 | 208 | if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err; |
| 204 | 209 | if( rc==401 ){ |
| 205 | - g.fUseHttpAuth = 1; | |
| 210 | + fUseHttpAuth = 1; | |
| 206 | 211 | transport_close(GLOBAL_URL()); |
| 207 | 212 | if( --maxRedirect == 0 ){ |
| 208 | 213 | fossil_fatal("http authorization limit exceeded"); |
| 209 | 214 | } |
| 210 | 215 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 211 | 216 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -76,10 +76,15 @@ | |
| 76 | blob_reset(&pw); |
| 77 | blob_reset(&sig); |
| 78 | blob_reset(&nonce); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | ** Construct an appropriate HTTP request header. Write the header |
| 83 | ** into pHdr. This routine initializes the pHdr blob. pPayload is |
| 84 | ** the complete payload (including the login card) already compressed. |
| 85 | */ |
| @@ -96,11 +101,11 @@ | |
| 96 | } |
| 97 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 98 | if( g.urlProxyAuth ){ |
| 99 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 100 | } |
| 101 | if( g.urlPasswd && g.urlUser && g.fUseHttpAuth ){ |
| 102 | char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd); |
| 103 | char *zEncoded = encode64(zCredentials, -1); |
| 104 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 105 | fossil_free(zEncoded); |
| 106 | fossil_free(zCredentials); |
| @@ -200,11 +205,11 @@ | |
| 200 | while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){ |
| 201 | /* printf("[%s]\n", zLine); fflush(stdout); */ |
| 202 | if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){ |
| 203 | if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err; |
| 204 | if( rc==401 ){ |
| 205 | g.fUseHttpAuth = 1; |
| 206 | transport_close(GLOBAL_URL()); |
| 207 | if( --maxRedirect == 0 ){ |
| 208 | fossil_fatal("http authorization limit exceeded"); |
| 209 | } |
| 210 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 211 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -76,10 +76,15 @@ | |
| 76 | blob_reset(&pw); |
| 77 | blob_reset(&sig); |
| 78 | blob_reset(&nonce); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | ** Use HTTP Basic Authorization if a 401 is seen. |
| 83 | */ |
| 84 | static int fUseHttpAuth = 0; |
| 85 | |
| 86 | /* |
| 87 | ** Construct an appropriate HTTP request header. Write the header |
| 88 | ** into pHdr. This routine initializes the pHdr blob. pPayload is |
| 89 | ** the complete payload (including the login card) already compressed. |
| 90 | */ |
| @@ -96,11 +101,11 @@ | |
| 101 | } |
| 102 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 103 | if( g.urlProxyAuth ){ |
| 104 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 105 | } |
| 106 | if( g.urlPasswd && g.urlUser && fUseHttpAuth ){ |
| 107 | char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd); |
| 108 | char *zEncoded = encode64(zCredentials, -1); |
| 109 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 110 | fossil_free(zEncoded); |
| 111 | fossil_free(zCredentials); |
| @@ -200,11 +205,11 @@ | |
| 205 | while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){ |
| 206 | /* printf("[%s]\n", zLine); fflush(stdout); */ |
| 207 | if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){ |
| 208 | if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err; |
| 209 | if( rc==401 ){ |
| 210 | fUseHttpAuth = 1; |
| 211 | transport_close(GLOBAL_URL()); |
| 212 | if( --maxRedirect == 0 ){ |
| 213 | fossil_fatal("http authorization limit exceeded"); |
| 214 | } |
| 215 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 216 |
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -139,11 +139,10 @@ | ||
| 139 | 139 | int fSqlTrace; /* True if --sqltrace flag is present */ |
| 140 | 140 | int fSqlStats; /* True if --sqltrace or --sqlstats are present */ |
| 141 | 141 | int fSqlPrint; /* True if -sqlprint flag is present */ |
| 142 | 142 | int fQuiet; /* True if -quiet flag is present */ |
| 143 | 143 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 144 | - int fUseHttpAuth; /* Use HTTP Basic Authentication in requests */ | |
| 145 | 144 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 146 | 145 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 147 | 146 | int fSshClient; /* HTTP client flags for SSH client */ |
| 148 | 147 | char *zSshCmd; /* SSH command string */ |
| 149 | 148 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| @@ -649,11 +648,10 @@ | ||
| 649 | 648 | g.fSshClient = 0; |
| 650 | 649 | g.zSshCmd = 0; |
| 651 | 650 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 652 | 651 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 653 | 652 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 654 | - g.fUseHttpAuth = 0; | |
| 655 | 653 | g.zLogin = find_option("user", "U", 1); |
| 656 | 654 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 657 | 655 | g.zErrlog = find_option("errorlog", 0, 1); |
| 658 | 656 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 659 | 657 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 660 | 658 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -139,11 +139,10 @@ | |
| 139 | int fSqlTrace; /* True if --sqltrace flag is present */ |
| 140 | int fSqlStats; /* True if --sqltrace or --sqlstats are present */ |
| 141 | int fSqlPrint; /* True if -sqlprint flag is present */ |
| 142 | int fQuiet; /* True if -quiet flag is present */ |
| 143 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 144 | int fUseHttpAuth; /* Use HTTP Basic Authentication in requests */ |
| 145 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 146 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 147 | int fSshClient; /* HTTP client flags for SSH client */ |
| 148 | char *zSshCmd; /* SSH command string */ |
| 149 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| @@ -649,11 +648,10 @@ | |
| 649 | g.fSshClient = 0; |
| 650 | g.zSshCmd = 0; |
| 651 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 652 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 653 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 654 | g.fUseHttpAuth = 0; |
| 655 | g.zLogin = find_option("user", "U", 1); |
| 656 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 657 | g.zErrlog = find_option("errorlog", 0, 1); |
| 658 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 659 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 660 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -139,11 +139,10 @@ | |
| 139 | int fSqlTrace; /* True if --sqltrace flag is present */ |
| 140 | int fSqlStats; /* True if --sqltrace or --sqlstats are present */ |
| 141 | int fSqlPrint; /* True if -sqlprint flag is present */ |
| 142 | int fQuiet; /* True if -quiet flag is present */ |
| 143 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 144 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 145 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 146 | int fSshClient; /* HTTP client flags for SSH client */ |
| 147 | char *zSshCmd; /* SSH command string */ |
| 148 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| @@ -649,11 +648,10 @@ | |
| 648 | g.fSshClient = 0; |
| 649 | g.zSshCmd = 0; |
| 650 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 651 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 652 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 653 | g.zLogin = find_option("user", "U", 1); |
| 654 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 655 | g.zErrlog = find_option("errorlog", 0, 1); |
| 656 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 657 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 658 |