squash
This commit is contained in:
parent
27c8c12420
commit
521ae7f60e
|
@ -9,6 +9,7 @@ from sanic.exceptions import MethodNotSupported
|
||||||
from sanic.log import logger
|
from sanic.log import logger
|
||||||
from sanic.response import text
|
from sanic.response import text
|
||||||
|
|
||||||
|
|
||||||
ASGI_HOST = "mockserver"
|
ASGI_HOST = "mockserver"
|
||||||
HOST = "127.0.0.1"
|
HOST = "127.0.0.1"
|
||||||
PORT = None
|
PORT = None
|
||||||
|
@ -94,7 +95,9 @@ class SanicTestClient:
|
||||||
@self.app.exception(MethodNotSupported)
|
@self.app.exception(MethodNotSupported)
|
||||||
async def error_handler(request, exception):
|
async def error_handler(request, exception):
|
||||||
if request.method in ["HEAD", "PATCH", "PUT", "DELETE"]:
|
if request.method in ["HEAD", "PATCH", "PUT", "DELETE"]:
|
||||||
return text("", exception.status_code, headers=exception.headers)
|
return text(
|
||||||
|
"", exception.status_code, headers=exception.headers
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return self.app.error_handler.default(request, exception)
|
return self.app.error_handler.default(request, exception)
|
||||||
|
|
||||||
|
@ -110,7 +113,9 @@ class SanicTestClient:
|
||||||
host, port = sock.getsockname()
|
host, port = sock.getsockname()
|
||||||
self.port = port
|
self.port = port
|
||||||
|
|
||||||
if uri.startswith(("http:", "https:", "ftp:", "ftps://", "//", "ws:", "wss:")):
|
if uri.startswith(
|
||||||
|
("http:", "https:", "ftp:", "ftps://", "//", "ws:", "wss:")
|
||||||
|
):
|
||||||
url = uri
|
url = uri
|
||||||
else:
|
else:
|
||||||
uri = uri if uri.startswith("/") else f"/{uri}"
|
uri = uri if uri.startswith("/") else f"/{uri}"
|
||||||
|
@ -242,7 +247,9 @@ class SanicASGITestClient(httpx.AsyncClient):
|
||||||
headers.setdefault("sec-websocket-key", "testserver==")
|
headers.setdefault("sec-websocket-key", "testserver==")
|
||||||
headers.setdefault("sec-websocket-version", "13")
|
headers.setdefault("sec-websocket-version", "13")
|
||||||
if subprotocols is not None:
|
if subprotocols is not None:
|
||||||
headers.setdefault("sec-websocket-protocol", ", ".join(subprotocols))
|
headers.setdefault(
|
||||||
|
"sec-websocket-protocol", ", ".join(subprotocols)
|
||||||
|
)
|
||||||
|
|
||||||
scope = {
|
scope = {
|
||||||
"type": "websocket",
|
"type": "websocket",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user