Skip to content

Commit 4ac90ba

Browse files
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) <noreply@anthropic.com>
1 parent 3f99ebe commit 4ac90ba

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Doc/library/urllib.request.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,10 @@ AbstractBasicAuthHandler Objects
10501050
authenticate for, *req* should be the (failed) :class:`Request` object, and
10511051
*headers* should be the error headers.
10521052

1053+
*headers* must be a mapping-like object with case-insensitive lookup
1054+
that implements the ``get_all()`` method,
1055+
such as :class:`email.message.Message` or :class:`wsgiref.headers.Headers`.
1056+
10531057
*host* is either an authority (e.g. ``"python.org"``) or a URL containing an
10541058
authority component (e.g. ``"https://python.org/"``). In either case, the
10551059
authority must not contain a userinfo component (so, ``"python.org"`` and
@@ -1091,6 +1095,9 @@ AbstractDigestAuthHandler Objects
10911095
should be the (failed) :class:`Request` object, and *headers* should be the
10921096
error headers.
10931097

1098+
*headers* must be a mapping-like object with case-insensitive lookup,
1099+
such as :class:`email.message.Message` or :class:`wsgiref.headers.Headers`.
1100+
10941101

10951102
.. _http-digest-auth-handler:
10961103

0 commit comments

Comments
 (0)