File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222from .headers import Headers
2323from .interfaces import _IFieldStorage , _IXSSSafeFieldStorage
24+ from .methods import POST , PUT , PATCH , DELETE
2425
2526
2627class QueryParams (_IXSSSafeFieldStorage ):
@@ -410,8 +411,15 @@ def form_data(self) -> Union[FormData, None]:
410411 return self ._form_data
411412
412413 def json (self ) -> Union [dict , None ]:
413- """Body of the request, as a JSON-decoded dictionary. Only available for POST requests."""
414- return json .loads (self .body ) if (self .body and self .method == "POST" ) else None
414+ """
415+ Body of the request, as a JSON-decoded dictionary.
416+ Only available for POST, PUT, PATCH and DELETE requests.
417+ """
418+ return (
419+ json .loads (self .body )
420+ if (self .body and self .method in (POST , PUT , PATCH , DELETE ))
421+ else None
422+ )
415423
416424 @property
417425 def _raw_header_bytes (self ) -> bytes :
You can’t perform that action at this time.
0 commit comments