Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | fc82b2334b | 
| @@ -894,7 +894,6 @@ class Sanic(BaseSanic, StartupMixin, metaclass=TouchUpMeta): | |||||||
|         ] = None |         ] = None | ||||||
|         run_middleware = True |         run_middleware = True | ||||||
|         try: |         try: | ||||||
|  |  | ||||||
|             await self.dispatch( |             await self.dispatch( | ||||||
|                 "http.routing.before", |                 "http.routing.before", | ||||||
|                 inline=True, |                 inline=True, | ||||||
| @@ -926,7 +925,6 @@ class Sanic(BaseSanic, StartupMixin, metaclass=TouchUpMeta): | |||||||
|                 and request.stream.request_body |                 and request.stream.request_body | ||||||
|                 and not route.extra.ignore_body |                 and not route.extra.ignore_body | ||||||
|             ): |             ): | ||||||
|  |  | ||||||
|                 if hasattr(handler, "is_stream"): |                 if hasattr(handler, "is_stream"): | ||||||
|                     # Streaming handler: lift the size limit |                     # Streaming handler: lift the size limit | ||||||
|                     request.stream.request_max_size = float("inf") |                     request.stream.request_max_size = float("inf") | ||||||
|   | |||||||
| @@ -4,7 +4,6 @@ from sanic.compat import UpperStrEnum | |||||||
|  |  | ||||||
|  |  | ||||||
| class HTTPMethod(UpperStrEnum): | class HTTPMethod(UpperStrEnum): | ||||||
|  |  | ||||||
|     GET = auto() |     GET = auto() | ||||||
|     POST = auto() |     POST = auto() | ||||||
|     PUT = auto() |     PUT = auto() | ||||||
| @@ -15,7 +14,6 @@ class HTTPMethod(UpperStrEnum): | |||||||
|  |  | ||||||
|  |  | ||||||
| class LocalCertCreator(UpperStrEnum): | class LocalCertCreator(UpperStrEnum): | ||||||
|  |  | ||||||
|     AUTO = auto() |     AUTO = auto() | ||||||
|     TRUSTME = auto() |     TRUSTME = auto() | ||||||
|     MKCERT = auto() |     MKCERT = auto() | ||||||
|   | |||||||
| @@ -126,7 +126,6 @@ class CertCreator(ABC): | |||||||
|         local_tls_key, |         local_tls_key, | ||||||
|         local_tls_cert, |         local_tls_cert, | ||||||
|     ) -> CertCreator: |     ) -> CertCreator: | ||||||
|  |  | ||||||
|         creator: Optional[CertCreator] = None |         creator: Optional[CertCreator] = None | ||||||
|  |  | ||||||
|         cert_creator_options: Tuple[ |         cert_creator_options: Tuple[ | ||||||
|   | |||||||
| @@ -1109,7 +1109,6 @@ class StartupMixin(metaclass=SanicMeta): | |||||||
|         app: StartupMixin, |         app: StartupMixin, | ||||||
|         server_info: ApplicationServerInfo, |         server_info: ApplicationServerInfo, | ||||||
|     ) -> None:  # no cov |     ) -> None:  # no cov | ||||||
|  |  | ||||||
|         try: |         try: | ||||||
|             # We should never get to this point without a server |             # We should never get to this point without a server | ||||||
|             # This is primarily to keep mypy happy |             # This is primarily to keep mypy happy | ||||||
|   | |||||||
| @@ -146,7 +146,6 @@ class Request: | |||||||
|         head: bytes = b"", |         head: bytes = b"", | ||||||
|         stream_id: int = 0, |         stream_id: int = 0, | ||||||
|     ): |     ): | ||||||
|  |  | ||||||
|         self.raw_url = url_bytes |         self.raw_url = url_bytes | ||||||
|         try: |         try: | ||||||
|             self._parsed_url = parse_url(url_bytes) |             self._parsed_url = parse_url(url_bytes) | ||||||
|   | |||||||
| @@ -232,7 +232,7 @@ class JSONResponse(HTTPResponse): | |||||||
|         body: Optional[Any] = None, |         body: Optional[Any] = None, | ||||||
|         status: int = 200, |         status: int = 200, | ||||||
|         headers: Optional[Union[Header, Dict[str, str]]] = None, |         headers: Optional[Union[Header, Dict[str, str]]] = None, | ||||||
|         content_type: Optional[str] = None, |         content_type: str = "application/json", | ||||||
|         dumps: Optional[Callable[..., str]] = None, |         dumps: Optional[Callable[..., str]] = None, | ||||||
|         **kwargs: Any, |         **kwargs: Any, | ||||||
|     ): |     ): | ||||||
|   | |||||||
| @@ -94,7 +94,6 @@ def watchdog(sleep_interval, reload_dirs): | |||||||
|  |  | ||||||
|     try: |     try: | ||||||
|         while True: |         while True: | ||||||
|  |  | ||||||
|             changed = set() |             changed = set() | ||||||
|             for filename in itertools.chain( |             for filename in itertools.chain( | ||||||
|                 _iter_module_files(), |                 _iter_module_files(), | ||||||
|   | |||||||
| @@ -52,7 +52,6 @@ class WebsocketFrameAssembler: | |||||||
|         paused: bool |         paused: bool | ||||||
|  |  | ||||||
|     def __init__(self, protocol) -> None: |     def __init__(self, protocol) -> None: | ||||||
|  |  | ||||||
|         self.protocol = protocol |         self.protocol = protocol | ||||||
|  |  | ||||||
|         self.read_mutex = asyncio.Lock() |         self.read_mutex = asyncio.Lock() | ||||||
|   | |||||||
| @@ -686,7 +686,6 @@ class WebsocketImplProtocol: | |||||||
|         :raises TypeError: for unsupported inputs |         :raises TypeError: for unsupported inputs | ||||||
|         """ |         """ | ||||||
|         async with self.conn_mutex: |         async with self.conn_mutex: | ||||||
|  |  | ||||||
|             if self.ws_proto.state in (CLOSED, CLOSING): |             if self.ws_proto.state in (CLOSED, CLOSING): | ||||||
|                 raise WebsocketClosed( |                 raise WebsocketClosed( | ||||||
|                     "Cannot write to websocket interface after it is closed." |                     "Cannot write to websocket interface after it is closed." | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ class TouchUpMeta(SanicMeta): | |||||||
|         methods = attrs.get("__touchup__") |         methods = attrs.get("__touchup__") | ||||||
|         attrs["__touched__"] = False |         attrs["__touched__"] = False | ||||||
|         if methods: |         if methods: | ||||||
|  |  | ||||||
|             for method in methods: |             for method in methods: | ||||||
|                 if method not in attrs: |                 if method not in attrs: | ||||||
|                     raise SanicException( |                     raise SanicException( | ||||||
|   | |||||||
| @@ -75,7 +75,6 @@ def load_module_from_file_location( | |||||||
|         location = location.decode(encoding) |         location = location.decode(encoding) | ||||||
|  |  | ||||||
|     if isinstance(location, Path) or "/" in location or "$" in location: |     if isinstance(location, Path) or "/" in location or "$" in location: | ||||||
|  |  | ||||||
|         if not isinstance(location, Path): |         if not isinstance(location, Path): | ||||||
|             # A) Check if location contains any environment variables |             # A) Check if location contains any environment variables | ||||||
|             #    in format ${some_env_var}. |             #    in format ${some_env_var}. | ||||||
|   | |||||||
| @@ -213,3 +213,12 @@ def test_pop_list(json_app: Sanic): | |||||||
|  |  | ||||||
|     _, resp = json_app.test_client.get("/json-pop") |     _, resp = json_app.test_client.get("/json-pop") | ||||||
|     assert resp.body == json_dumps(["b"]).encode() |     assert resp.body == json_dumps(["b"]).encode() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def test_json_response_class_sets_proper_content_type(json_app: Sanic): | ||||||
|  |     @json_app.get("/json-class") | ||||||
|  |     async def handler(request: Request): | ||||||
|  |         return JSONResponse(JSON_BODY) | ||||||
|  |  | ||||||
|  |     _, resp = json_app.test_client.get("/json-class") | ||||||
|  |     assert resp.headers["content-type"] == "application/json" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user