Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_concrete_http_class():
config = Config(app=asgi_app, http=protocols.http.h11_impl.H11Protocol)
config.load()
assert config.http_protocol_class is protocols.http.h11_impl.H11Protocol
def test_concrete_http_class():
config = Config(app=asgi_app, http=protocols.http.h11_impl.H11Protocol)
config.load()
assert config.http_protocol_class is protocols.http.h11_impl.H11Protocol
import h11
import pytest
from tests.response import Response
from uvicorn.config import Config
from uvicorn.main import ServerState
from uvicorn.protocols.http.h11_impl import H11Protocol
from uvicorn.protocols.websockets.wsproto_impl import WSProtocol
try:
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
except ImportError: # pragma: nocover
HttpToolsProtocol = None
HTTP_PROTOCOLS = [p for p in [H11Protocol, HttpToolsProtocol] if p is not None]
SIMPLE_GET_REQUEST = b"\r\n".join([b"GET / HTTP/1.1", b"Host: example.org", b"", b""])
SIMPLE_HEAD_REQUEST = b"\r\n".join([b"HEAD / HTTP/1.1", b"Host: example.org", b"", b""])
SIMPLE_POST_REQUEST = b"\r\n".join(
[
b"POST / HTTP/1.1",
b"Host: example.org",
b"Content-Type: application/json",
b"Content-Length: 18",
b"",
b'{"hello": "world"}',
]
)
def protocol_cls(cls):
from uvicorn.protocols.http.h11_impl import H11Protocol
return H11Protocol
try:
import httptools
except ImportError as exc: # pragma: no cover
from uvicorn.protocols.http.h11_impl import H11Protocol
AutoHTTPProtocol = H11Protocol
else:
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
AutoHTTPProtocol = HttpToolsProtocol