diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-08-08 05:32:20 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-08-08 05:32:20 +0200 |
commit | c8d1a885f84cb26035c0f2d6827e74d1338c7a16 (patch) | |
tree | 3877006a164acc3d9e27a4dbe4bd471881bb9592 /sys/src/cmd/webfs | |
parent | 038a61554939d02c17f4bcd4a6f0f150c40237d4 (diff) |
webfs: avoid retry loops when we got a bad key in factotum
Diffstat (limited to 'sys/src/cmd/webfs')
-rw-r--r-- | sys/src/cmd/webfs/http.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index be800c4a2..01def74b5 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -518,7 +518,7 @@ catch(void *, char *msg) void http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) { - int i, l, n, try, pid, fd, cfd, needlength, chunked, retry, nobody; + int i, l, n, try, pid, fd, cfd, needlength, chunked, retry, nobody, badauth; char *s, *x, buf[8192+2], status[256], method[16], *host; vlong length, offset; Url ru, tu, *nu; @@ -560,6 +560,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) pid = 0; host = nil; needlength = 0; + badauth = 0; for(try = 0; try < 12; try++){ strcpy(status, "0 No status"); if(u == nil || (strcmp(u->scheme, "http") && strcmp(u->scheme, "https"))){ @@ -864,8 +865,11 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) u = nu; if(0){ case 401: /* Unauthorized */ - if(x = lookkey(shdr, "Authorization")) + if(x = lookkey(shdr, "Authorization")){ flushauth(nil, x); + if(badauth++) + goto Error; + } if(hauthenticate(u, &ru, method, "WWW-Authenticate", rhdr) < 0){ Autherror: h->cancel = 1; @@ -879,8 +883,11 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) case 407: /* Proxy Auth */ if(proxy == nil) goto Error; - if(x = lookkey(shdr, "Proxy-Authorization")) + if(x = lookkey(shdr, "Proxy-Authorization")){ flushauth(proxy, x); + if(badauth++) + goto Error; + } if(hauthenticate(proxy, proxy, method, "Proxy-Authenticate", rhdr) < 0) goto Autherror; } |