From 4ac90baa7dca538faff9fc10f5ebf048a4783215 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 12 Aug 2026 21:25:54 +0300 Subject: [PATCH] gh-89735: Document requirements for the *headers* argument Both handlers look up the header name in lowercase, and the basic one needs get_all(), so a plain dict does not work. Co-Authored-By: Claude Opus 5 (1M context) --- Doc/library/urllib.request.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 95e4d2627c8b23..5c8333d3dc8a7d 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -1050,6 +1050,10 @@ AbstractBasicAuthHandler Objects authenticate for, *req* should be the (failed) :class:`Request` object, and *headers* should be the error headers. + *headers* must be a mapping-like object with case-insensitive lookup + that implements the ``get_all()`` method, + such as :class:`email.message.Message` or :class:`wsgiref.headers.Headers`. + *host* is either an authority (e.g. ``"python.org"``) or a URL containing an authority component (e.g. ``"https://python.org/"``). In either case, the authority must not contain a userinfo component (so, ``"python.org"`` and @@ -1091,6 +1095,9 @@ AbstractDigestAuthHandler Objects should be the (failed) :class:`Request` object, and *headers* should be the error headers. + *headers* must be a mapping-like object with case-insensitive lookup, + such as :class:`email.message.Message` or :class:`wsgiref.headers.Headers`. + .. _http-digest-auth-handler: