Skip to content

Commit

Permalink
🐛 Fix the need of httptools on minimal installation (encode#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Oct 29, 2022
1 parent dd94c26 commit 086c205
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions uvicorn/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
import time
from email.utils import formatdate
from types import FrameType
from typing import Any, List, Optional, Set, Tuple, Union
from typing import TYPE_CHECKING, Any, List, Optional, Set, Tuple, Union

import click

from uvicorn._handlers.http import handle_http
from uvicorn.config import Config
from uvicorn.protocols.http.h11_impl import H11Protocol
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
from uvicorn.protocols.websockets.websockets_impl import WebSocketProtocol
from uvicorn.protocols.websockets.wsproto_impl import WSProtocol

if TYPE_CHECKING:
from uvicorn.protocols.http.h11_impl import H11Protocol
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
from uvicorn.protocols.websockets.websockets_impl import WebSocketProtocol
from uvicorn.protocols.websockets.wsproto_impl import WSProtocol

Protocols = Union[H11Protocol, HttpToolsProtocol, WSProtocol, WebSocketProtocol]

if sys.platform != "win32":
from asyncio import start_unix_server as _start_unix_server
Expand All @@ -35,8 +39,6 @@ async def _start_unix_server(*args: Any, **kwargs: Any) -> Any:

logger = logging.getLogger("uvicorn.error")

Protocols = Union[H11Protocol, HttpToolsProtocol, WSProtocol, WebSocketProtocol]


class ServerState:
"""
Expand All @@ -45,7 +47,7 @@ class ServerState:

def __init__(self) -> None:
self.total_requests = 0
self.connections: Set[Protocols] = set()
self.connections: Set["Protocols"] = set()
self.tasks: Set[asyncio.Task] = set()
self.default_headers: List[Tuple[bytes, bytes]] = []

Expand Down

0 comments on commit 086c205

Please sign in to comment.