Fix for --http2 silently ignoring HTTP authentication (Basic sent preemptively, others rejected)

This commit is contained in:
Miroslav Štampar 2026-11-12 17:20:51 +01:00
parent cdb787faea
commit 04f0987e81
3 changed files with 10 additions and 1 deletions

View file

@ -736,6 +736,10 @@ class Connect(object):
from lib.request.http2 import open_url as http2OpenUrl
from lib.request.http2 import proxy_tuple
# Note: (preemptive) Basic authentication, as urllib's handlers are bypassed
if (conf.authType or "").lower() == AUTH_TYPE.BASIC and conf.authUsername is not None and HTTP_HEADER.AUTHORIZATION not in headers:
headers[HTTP_HEADER.AUTHORIZATION] = "Basic %s" % encodeBase64("%s:%s" % (conf.authUsername, conf.authPassword or ""), binary=False)
try:
h2proxy = proxy_tuple(conf.proxy, conf.proxyCred)
except ValueError: