@@ -179,8 +179,7 @@ class Request:
179
179
180
180
Example::
181
181
182
- request.client_address
183
- # ('192.168.137.1', 40684)
182
+ request.client_address # ('192.168.137.1', 40684)
184
183
"""
185
184
186
185
method : str
@@ -195,9 +194,11 @@ class Request:
195
194
196
195
Example::
197
196
198
- request = Request(raw_request=b"GET /?foo=bar HTTP/1.1...")
199
- request.query_params
200
- # QueryParams({"foo": "bar"})
197
+ request = Request(..., raw_request=b"GET /?foo=bar&baz=qux HTTP/1.1...")
198
+
199
+ request.query_params # QueryParams({"foo": "bar"})
200
+ request.query_params["foo"] # "bar"
201
+ request.query_params.get_list("baz") # ["qux"]
201
202
"""
202
203
203
204
http_version : str
@@ -255,7 +256,47 @@ def body(self, body: bytes) -> None:
255
256
256
257
@property
257
258
def form_data (self ) -> Union [FormData , None ]:
258
- """POST data of the request"""
259
+ """
260
+ POST data of the request.
261
+
262
+ Example::
263
+
264
+ # application/x-www-form-urlencoded
265
+ request = Request(...,
266
+ raw_request=b\" \" \" ...
267
+ foo=bar&baz=qux\" \" \"
268
+ )
269
+
270
+ # or
271
+
272
+ # multipart/form-data
273
+ request = Request(...,
274
+ raw_request=b\" \" \" ...
275
+ --boundary
276
+ Content-Disposition: form-data; name="foo"
277
+
278
+ bar
279
+ --boundary
280
+ Content-Disposition: form-data; name="baz"
281
+
282
+ qux
283
+ --boundary--\" \" \"
284
+ )
285
+
286
+ # or
287
+
288
+ # text/plain
289
+ request = Request(...,
290
+ raw_request=b\" \" \" ...
291
+ foo=bar
292
+ baz=qux
293
+ \" \" \"
294
+ )
295
+
296
+ request.form_data # FormData({'foo': ['bar'], 'baz': ['qux']})
297
+ request.form_data["foo"] # "bar"
298
+ request.form_data.get_list("baz") # ["qux"]
299
+ """
259
300
if self ._form_data is None and self .method == "POST" :
260
301
self ._form_data = FormData (self .body , self .headers ["Content-Type" ])
261
302
return self ._form_data
0 commit comments