Skip to content

Commit 5aea936

Browse files
committed
Updated docstrings in Request
1 parent 5f9a8d4 commit 5aea936

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

adafruit_httpserver/request.py

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ class Request:
179179
180180
Example::
181181
182-
request.client_address
183-
# ('192.168.137.1', 40684)
182+
request.client_address # ('192.168.137.1', 40684)
184183
"""
185184

186185
method: str
@@ -195,9 +194,11 @@ class Request:
195194
196195
Example::
197196
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"]
201202
"""
202203

203204
http_version: str
@@ -255,7 +256,47 @@ def body(self, body: bytes) -> None:
255256

256257
@property
257258
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+
"""
259300
if self._form_data is None and self.method == "POST":
260301
self._form_data = FormData(self.body, self.headers["Content-Type"])
261302
return self._form_data

0 commit comments

Comments
 (0)