add __repr__ for sanic request

This commit is contained in:
huyuhan 2017-09-15 20:56:44 +08:00
parent 12dafd07b8
commit 77f70a0792

View File

@ -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"
@ -69,9 +70,9 @@ class Request(dict):
self.stream = None self.stream = None
def __repr__(self): def __repr__(self):
if self.method is None or not self._parsed_url: if self.method is None or not self.path:
return '<%s>' % self.__class__.__name__ return '<%s>' % self.__class__.__name__
return '<%s: %s %r>' % (self.__class__.__name__, self.method, self.path) return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.path)
@property @property
def json(self): def json(self):