Skip to content

Commit 6ef83f5

Browse files
[PR #10301/77f25a0a backport][3.11] Update docs for aiohttp.request (#10307)
**This is a backport of PR #10301 as merged into master (77f25a0).** ## What do these changes do? Noticed that the content of `aiohttp.request` reference in documentation needs to be changed after #10300 . This pr update docs for that. ## Are there changes in behavior for the user? ## Is it a substantial burden for the maintainers to support this? ## Related issue number ## Checklist - [ ] I think the code is well written - [ ] Unit tests for the changes exist - [x] Documentation reflects the changes - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt` * The format is &lt;Name&gt; &lt;Surname&gt;. * Please keep alphabetical order, the file is sorted by names. - [ ] Add a new news fragment into the `CHANGES/` folder Co-authored-by: Cycloctane <[email protected]>
1 parent 0c32bc8 commit 6ef83f5

File tree

1 file changed

+97
-28
lines changed

1 file changed

+97
-28
lines changed

Diff for: docs/client_reference.rst

+97-28
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ The client session supports the context manager protocol for self closing.
513513
.. versionadded:: 3.0
514514

515515
:param str server_hostname: Sets or overrides the host name that the
516-
target servers certificate will be matched against.
516+
target server's certificate will be matched against.
517517

518518
See :py:meth:`asyncio.loop.create_connection` for more information.
519519

@@ -850,14 +850,21 @@ certification chaining.
850850

851851
.. function:: request(method, url, *, params=None, data=None, \
852852
json=None,\
853-
headers=None, cookies=None, auth=None, \
853+
cookies=None, headers=None, skip_auto_headers=None, auth=None, \
854854
allow_redirects=True, max_redirects=10, \
855-
encoding='utf-8', \
856-
version=HttpVersion(major=1, minor=1), \
857-
compress=None, chunked=None, expect100=False, raise_for_status=False, \
855+
compress=False, chunked=None, expect100=False, raise_for_status=None, \
856+
read_until_eof=True, \
857+
proxy=None, proxy_auth=None, \
858+
timeout=sentinel, ssl=True, \
859+
server_hostname=None, \
860+
proxy_headers=None, \
861+
trace_request_ctx=None, \
858862
read_bufsize=None, \
859-
connector=None, loop=None,\
860-
read_until_eof=True, timeout=sentinel)
863+
auto_decompress=None, \
864+
max_line_size=None, \
865+
max_field_size=None, \
866+
version=aiohttp.HttpVersion11, \
867+
connector=None)
861868
:async:
862869

863870
Asynchronous context manager for performing an asynchronous HTTP
@@ -870,8 +877,20 @@ certification chaining.
870877
be encoded with :class:`~yarl.URL` (see :class:`~yarl.URL`
871878
to skip encoding).
872879

873-
:param dict params: Parameters to be sent in the query
874-
string of the new request (optional)
880+
:param params: Mapping, iterable of tuple of *key*/*value* pairs or
881+
string to be sent as parameters in the query
882+
string of the new request. Ignored for subsequent
883+
redirected requests (optional)
884+
885+
Allowed values are:
886+
887+
- :class:`collections.abc.Mapping` e.g. :class:`dict`,
888+
:class:`multidict.MultiDict` or
889+
:class:`multidict.MultiDictProxy`
890+
- :class:`collections.abc.Iterable` e.g. :class:`tuple` or
891+
:class:`list`
892+
- :class:`str` with preferably url-encoded content
893+
(**Warning:** content will not be encoded by *aiohttp*)
875894

876895
:param data: The data to send in the body of the request. This can be a
877896
:class:`FormData` object or anything that can be passed into
@@ -881,28 +900,46 @@ certification chaining.
881900
:param json: Any json compatible python object (optional). *json* and *data*
882901
parameters could not be used at the same time.
883902

903+
:param dict cookies: HTTP Cookies to send with the request (optional)
904+
884905
:param dict headers: HTTP Headers to send with the request (optional)
885906

886-
:param dict cookies: Cookies to send with the request (optional)
907+
:param skip_auto_headers: set of headers for which autogeneration
908+
should be skipped.
909+
910+
*aiohttp* autogenerates headers like ``User-Agent`` or
911+
``Content-Type`` if these headers are not explicitly
912+
passed. Using ``skip_auto_headers`` parameter allows to skip
913+
that generation.
914+
915+
Iterable of :class:`str` or :class:`~multidict.istr`
916+
(optional)
887917

888918
:param aiohttp.BasicAuth auth: an object that represents HTTP Basic
889919
Authorization (optional)
890920

891921
:param bool allow_redirects: Whether to process redirects or not.
892-
When ``True``, redirects are followed (up to ``max_redirects`` times)
893-
and logged into :attr:`ClientResponse.history` and ``trace_configs``.
894-
When ``False``, the original response is returned.
895-
``True`` by default (optional).
922+
When ``True``, redirects are followed (up to ``max_redirects`` times)
923+
and logged into :attr:`ClientResponse.history` and ``trace_configs``.
924+
When ``False``, the original response is returned.
925+
``True`` by default (optional).
896926

897-
:param aiohttp.protocol.HttpVersion version: Request HTTP version (optional)
927+
:param int max_redirects: Maximum number of redirects to follow.
928+
:exc:`TooManyRedirects` is raised if the number is exceeded.
929+
Ignored when ``allow_redirects=False``.
930+
``10`` by default.
898931

899932
:param bool compress: Set to ``True`` if request has to be compressed
900-
with deflate encoding.
901-
``False`` instructs aiohttp to not compress data.
933+
with deflate encoding. If `compress` can not be combined
934+
with a *Content-Encoding* and *Content-Length* headers.
902935
``None`` by default (optional).
903936

904937
:param int chunked: Enables chunked transfer encoding.
905-
``None`` by default (optional).
938+
It is up to the developer
939+
to decide how to chunk data streams. If chunking is enabled, aiohttp
940+
encodes the provided chunks in the "Transfer-encoding: chunked" format.
941+
If *chunked* is set, then the *Transfer-encoding* and *content-length*
942+
headers are disallowed. ``None`` by default (optional).
906943

907944
:param bool expect100: Expect 100-continue response from server.
908945
``False`` by default (optional).
@@ -916,28 +953,60 @@ certification chaining.
916953

917954
.. versionadded:: 3.4
918955

919-
:param aiohttp.BaseConnector connector: BaseConnector sub-class
920-
instance to support connection pooling.
921-
922956
:param bool read_until_eof: Read response until EOF if response
923957
does not have Content-Length header.
924958
``True`` by default (optional).
925959

960+
:param proxy: Proxy URL, :class:`str` or :class:`~yarl.URL` (optional)
961+
962+
:param aiohttp.BasicAuth proxy_auth: an object that represents proxy HTTP
963+
Basic Authorization (optional)
964+
965+
:param timeout: a :class:`ClientTimeout` settings structure, 300 seconds (5min)
966+
total timeout, 30 seconds socket connect timeout by default.
967+
968+
:param ssl: SSL validation mode. ``True`` for default SSL check
969+
(:func:`ssl.create_default_context` is used),
970+
``False`` for skip SSL certificate validation,
971+
:class:`aiohttp.Fingerprint` for fingerprint
972+
validation, :class:`ssl.SSLContext` for custom SSL
973+
certificate validation.
974+
975+
Supersedes *verify_ssl*, *ssl_context* and
976+
*fingerprint* parameters.
977+
978+
:param str server_hostname: Sets or overrides the host name that the
979+
target server's certificate will be matched against.
980+
981+
See :py:meth:`asyncio.loop.create_connection`
982+
for more information.
983+
984+
:param collections.abc.Mapping proxy_headers: HTTP headers to send to the proxy
985+
if the parameter proxy has been provided.
986+
987+
:param trace_request_ctx: Object used to give as a kw param for each new
988+
:class:`TraceConfig` object instantiated,
989+
used to give information to the
990+
tracers that is only available at request time.
991+
926992
:param int read_bufsize: Size of the read buffer (:attr:`ClientResponse.content`).
927993
``None`` by default,
928994
it means that the session global value is used.
929995

930996
.. versionadded:: 3.7
931997

932-
:param timeout: a :class:`ClientTimeout` settings structure, 300 seconds (5min)
933-
total timeout, 30 seconds socket connect timeout by default.
998+
:param bool auto_decompress: Automatically decompress response body.
999+
May be used to enable/disable auto decompression on a per-request basis.
9341000

935-
:param loop: :ref:`event loop<asyncio-event-loop>`
936-
used for processing HTTP requests.
937-
If param is ``None``, :func:`asyncio.get_event_loop`
938-
is used for getting default event loop.
1001+
:param int max_line_size: Maximum allowed size of lines in responses.
9391002

940-
.. deprecated:: 2.0
1003+
:param int max_field_size: Maximum allowed size of header fields in responses.
1004+
1005+
:param aiohttp.protocol.HttpVersion version: Request HTTP version,
1006+
``HTTP 1.1`` by default. (optional)
1007+
1008+
:param aiohttp.BaseConnector connector: BaseConnector sub-class
1009+
instance to support connection pooling. (optional)
9411010

9421011
:return ClientResponse: a :class:`client response <ClientResponse>` object.
9431012

0 commit comments

Comments
 (0)