Deleted Added
full compact
28c28
< * $FreeBSD: head/lib/libfetch/http.c 75891 2001-04-24 00:06:21Z archie $
---
> * $FreeBSD: head/lib/libfetch/http.c 77238 2001-05-26 19:37:15Z des $
297c297,298
< hdr_transfer_encoding
---
> hdr_transfer_encoding,
> hdr_www_authenticate
309a311
> { hdr_www_authenticate, "WWW-Authenticate" },
566a569,570
> DEBUG(fprintf(stderr, "usr: [\033[1m%s\033[m]\n", usr));
> DEBUG(fprintf(stderr, "pwd: [\033[1m%s\033[m]\n", pwd));
707a712
> need_auth = 0;
711d715
< need_auth = 0;
717c721
< retry:
---
>
745a750,755
> /* virtual host */
> if (url->port == _fetch_default_port(url->scheme))
> _http_cmd(fd, "Host: %s", host);
> else
> _http_cmd(fd, "Host: %s:%d", host, url->port);
>
756c766
< if (need_auth) {
---
> if (need_auth || *url->user || *url->pwd) {
761c771,773
< else {
---
> else if (fetchAuthMethod && fetchAuthMethod(url) == 0) {
> _http_basic_auth(fd, "Authorization", url->user, url->pwd);
> } else {
768,771d779
< if (url->port == _fetch_default_port(url->scheme))
< _http_cmd(fd, "Host: %s", host);
< else
< _http_cmd(fd, "Host: %s:%d", host, url->port);
803,805c811
< need_auth = 1;
< close(fd);
< goto retry;
---
> break;
869a876,880
> case hdr_www_authenticate:
> if (code != HTTP_NEED_AUTH)
> break;
> /* if we were smarter, we'd check the method and realm */
> break;
878,879c889,890
< /* we either have a hit, or a redirect with no Location: header */
< if (code == HTTP_OK || code == HTTP_PARTIAL || !new)
---
> /* we have a hit */
> if (code == HTTP_OK || code == HTTP_PARTIAL)
882c893,902
< /* we have a redirect */
---
> /* we need to provide authentication */
> if (code == HTTP_NEED_AUTH) {
> need_auth = 1;
> close(fd);
> fd = -1;
> continue;
> }
>
> /* all other cases: we got a redirect */
> need_auth = 0;
884a905,908
> if (!new) {
> DEBUG(fprintf(stderr, "redirect with no new location\n"));
> break;
> }
890c914
< /* no success */
---
> /* we failed, or ran out of retries */