http_parse_authenticate() set cs->valid = 1 unconditionally as soon as
it saw any WWW-Authenticate or Proxy-Authenticate header, regardless
of which scheme(s) the header actually offered. libfetch only
implements Basic and Digest; any other scheme (Negotiate, Bearer,
NTLM, ...) is parsed into a HTTPAS_UNKNOWN challenge and is otherwise
unusable.
Because the "valid" bit was already set, http_request_body() treated
such 401/407 responses as "we have a usable challenge, retry with
credentials" instead of failing immediately. This caused fetch(1) to
interactively prompt for a username/password it could never actually
use (since http_authorize() finds no Basic/Digest challenge to answer
with), confirmed against two servers that only offer schemes libfetch
does not support (WWW-Authenticate: Bearer, WWW-Authenticate:
Negotiate) -- in both cases fetch -v showed a prompt and a retried
connection before failing with "Unauthorized".
Only set cs->valid once a challenge is actually classified as Basic or
Digest. init_http_auth_challenges() already zero-initializes valid, so
a response offering only unsupported schemes now correctly leaves it
unset and fails immediately, with no prompt and no retry.
The existing "no usable auth" bailout in http_request_body() is now
also reached for this case (previously it was effectively unreachable,
since any auth header at all used to set valid); add the missing
http_seterr(conn->err) there so fetch reports "Unauthorized" instead
of a blank error message.
PR: 256677
MFC after: 1 week