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