From 3dffa05ffb229813156b71e10a85283bdaa26d5e Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Wed, 18 Jun 2025 20:09:43 +0100 Subject: [PATCH] Documentation improvements for the `Request` class --- docs/intro.rst | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index 3ce4b49..70ba0f7 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -601,6 +601,13 @@ The request object provides access to the request attributes, including: specified by the client, or ``None`` if no content type was specified. - :attr:`content_length `: The content length of the request, or 0 if no content length was specified. +- :attr:`json `: The parsed JSON data in the request + body. See :ref:`below ` for additional details. +- :attr:`form `: The parsed form data in the request + body, as a dictionary. See :ref:`below
` for additional details. +- :attr:`files `: A dictionary with the file uploads + included in the request body. Note that file uploads are only supported when + the :ref:`Multipart Forms` extension is used. - :attr:`client_addr `: The network address of the client, as a tuple (host, port). - :attr:`app `: The application instance that created the @@ -627,8 +634,8 @@ to use this attribute:: The client must set the ``Content-Type`` header to ``application/json`` for the ``json`` attribute of the request object to be populated. -URLEncoded Form Data -^^^^^^^^^^^^^^^^^^^^ +Form Data +^^^^^^^^^ The request object also supports standard HTML form submissions through the :attr:`form ` attribute, which presents the form data @@ -642,9 +649,10 @@ as a :class:`MultiDict ` object. Example:: return f'Hello {name}' .. note:: - Form submissions are only parsed when the ``Content-Type`` header is set by - the client to ``application/x-www-form-urlencoded``. Form submissions using - the ``multipart/form-data`` content type are currently not supported. + Form submissions automatically parsed when the ``Content-Type`` header is + set by the client to ``application/x-www-form-urlencoded``. For form + submissions that use the ``multipart/form-data`` content type the + :ref:`Multipart Forms` extension must be used. Accessing the Raw Request Body ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^