Merge pull request #944 from blazehu/master
add __repr__ for sanic request
This commit is contained in:
commit
4ce699e57f
|
@ -19,8 +19,9 @@ except ImportError:
|
||||||
from sanic.exceptions import InvalidUsage
|
from sanic.exceptions import InvalidUsage
|
||||||
from sanic.log import log
|
from sanic.log import log
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream"
|
DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream"
|
||||||
|
|
||||||
|
|
||||||
# HTTP/1.1: https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
|
# HTTP/1.1: https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
|
||||||
# > If the media type remains unknown, the recipient SHOULD treat it
|
# > If the media type remains unknown, the recipient SHOULD treat it
|
||||||
# > as type "application/octet-stream"
|
# > as type "application/octet-stream"
|
||||||
|
@ -68,6 +69,13 @@ class Request(dict):
|
||||||
self._cookies = None
|
self._cookies = None
|
||||||
self.stream = None
|
self.stream = None
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
if self.method is None or not self.path:
|
||||||
|
return '<{0}>'.format(self.__class__.__name__)
|
||||||
|
return '<{0}: {1} {2}>'.format(self.__class__.__name__,
|
||||||
|
self.method,
|
||||||
|
self.path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def json(self):
|
def json(self):
|
||||||
if self.parsed_json is None:
|
if self.parsed_json is None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user