add __repr__ for sanic request
This commit is contained in:
		| @@ -19,8 +19,9 @@ except ImportError: | ||||
| from sanic.exceptions import InvalidUsage | ||||
| from sanic.log import log | ||||
|  | ||||
|  | ||||
| DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream" | ||||
|  | ||||
|  | ||||
| # 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 | ||||
| # > as type "application/octet-stream" | ||||
| @@ -69,9 +70,9 @@ class Request(dict): | ||||
|         self.stream = None | ||||
|  | ||||
|     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: %s %r>' % (self.__class__.__name__, self.method, self.path) | ||||
|         return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.path) | ||||
|  | ||||
|     @property | ||||
|     def json(self): | ||||
| @@ -175,8 +176,8 @@ class Request(dict): | ||||
|             remote_addrs = [ | ||||
|                 addr for addr in [ | ||||
|                     addr.strip() for addr in forwarded_for | ||||
|                 ] if addr | ||||
|             ] | ||||
|                     ] if addr | ||||
|                 ] | ||||
|             if len(remote_addrs) > 0: | ||||
|                 self._remote_addr = remote_addrs[0] | ||||
|             else: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 huyuhan
					huyuhan