bpo-35153: Add headers parameter to xmlrpc.client.ServerProxy (GH-10308)

Allow to add HTTP headers to XML-RPC requests sent to the server.
This commit is contained in:
Cédric Krier 2019-02-19 17:18:50 +01:00 • committed by Victor Stinner
parent 513e9b4425
commit beda52ed36
4 changed files with 86 additions and 11 deletions

View file

@ -34,10 +34,7 @@ between conformable Python objects and XML on the wire.
.. class:: ServerProxy(uri, transport=None, encoding=None, verbose=False, \
allow_none=False, use_datetime=False, \
use_builtin_types=False, *, context=None)
.. versionchanged:: 3.3
The *use_builtin_types* flag was added.
use_builtin_types=False, *, headers=(), context=None)
A :class:`ServerProxy` instance is an object that manages communication with a
remote XML-RPC server. The required first argument is a URI (Uniform Resource
@ -59,9 +56,18 @@ between conformable Python objects and XML on the wire.
presented as :class:`bytes` objects; this flag is false by default.
:class:`datetime.datetime`, :class:`bytes` and :class:`bytearray` objects
may be passed to calls.
The *headers* parameter is an optional sequence of HTTP headers to send with
each request, expressed as a sequence of 2-tuples representing the header
name and value. (e.g. `[('Header-Name', 'value')]`).
The obsolete *use_datetime* flag is similar to *use_builtin_types* but it
applies only to date/time values.
.. versionchanged:: 3.3
The *use_builtin_types* flag was added.
.. versionchanged:: 3.8
The *headers* parameter was added.
Both the HTTP and HTTPS transports support the URL syntax extension for HTTP
Basic Authentication: ``http://user:pass@host:port/path``. The ``user:pass``
portion will be base64-encoded as an HTTP 'Authorization' header, and sent to