Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions stubs/gunicorn/gunicorn/asgi/parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ class ParseError(Exception): ...
class InvalidProxyLine(ParseError): ...
class InvalidProxyHeader(ParseError): ...

@type_check_only
class _ProxyProtocolInfo(TypedDict):
proxy_protocol: Literal["TCP4", "TCP6", "UDP4", "UDP6"]
client_addr: str
client_port: int
proxy_addr: str
proxy_port: int

@type_check_only
class _ProxyProtocolInfoUnknown(TypedDict):
proxy_protocol: Literal["UNKNOWN", "LOCAL", "UNSPEC"]
client_addr: None
client_port: None
proxy_addr: None
proxy_port: None

PP_V2_SIGNATURE: Final[bytes]
RFC9110_6_5_1_FORBIDDEN_TRAILER: Final[frozenset[bytes]]

Expand Down Expand Up @@ -38,22 +54,6 @@ class UnsupportedTransferCoding(ParseError): ...
class InvalidChunkSize(ParseError): ...
class InvalidChunkExtension(ParseError): ...

@type_check_only
class _ProxyProtocolInfo(TypedDict):
proxy_protocol: Literal["TCP4", "TCP6", "UDP4", "UDP6"]
client_addr: str
client_port: int
proxy_addr: str
proxy_port: int

@type_check_only
class _ProxyProtocolInfoUnknown(TypedDict):
proxy_protocol: Literal["UNKNOWN", "LOCAL", "UNSPEC"]
client_addr: None
client_port: None
proxy_addr: None
proxy_port: None

class PythonProtocol:
__slots__ = (
"_on_message_begin",
Expand Down Expand Up @@ -149,7 +149,7 @@ class CallbackRequest:
content_length: int
chunked: bool
must_close: bool
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
proxy_protocol_info: _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None

def __init__(self) -> None: ...
@classmethod
Expand Down
3 changes: 2 additions & 1 deletion stubs/gunicorn/gunicorn/asgi/uwsgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from gunicorn.config import Config
from gunicorn.uwsgi.message import UWSGIRequest

from .._types import _AddressType
from .parser import _ProxyProtocolInfo, _ProxyProtocolInfoUnknown

class AsyncUWSGIRequest(UWSGIRequest):
cfg: Config
Expand All @@ -26,7 +27,7 @@ class AsyncUWSGIRequest(UWSGIRequest):
uwsgi_vars: dict[str, str]
modifier1: int
modifier2: int
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
proxy_protocol_info: _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None
content_length: int
chunked: bool

Expand Down
3 changes: 2 additions & 1 deletion stubs/gunicorn/gunicorn/http/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from gunicorn.http.body import Body
from gunicorn.http.unreader import Unreader

from .._types import _AddressType
from ..asgi.parser import _ProxyProtocolInfo, _ProxyProtocolInfoUnknown

PP_V2_SIGNATURE: Final = b"\x0d\x0a\x0d\x0a\x00\x0d\x0a\x51\x55\x49\x54\x0a"

Expand Down Expand Up @@ -66,7 +67,7 @@ class Request(Message):
fragment: str | None
limit_request_line: int
req_number: int
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
proxy_protocol_info: _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None

def __init__(self, cfg: Config, unreader: Unreader, peer_addr: _AddressType, req_number: int = 1) -> None: ...
def get_data(self, unreader: Unreader, buf: io.BytesIO, stop: bool = False) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/gunicorn/gunicorn/http2/request.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from gunicorn.config import Config
from gunicorn.http2.stream import HTTP2Stream

from .._types import _AddressType
from ..asgi.parser import _ProxyProtocolInfo, _ProxyProtocolInfoUnknown

class HTTP2Body:
def __init__(self, data: ReadableBuffer) -> None: ...
Expand Down Expand Up @@ -33,7 +34,7 @@ class HTTP2Request:
body: HTTP2Body
must_close: bool
req_number: int
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
proxy_protocol_info: _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None
priority_weight: int
priority_depends_on: int

Expand Down
3 changes: 2 additions & 1 deletion stubs/gunicorn/gunicorn/uwsgi/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from gunicorn.http.body import Body
from gunicorn.http.unreader import Unreader

from .._types import _AddressType
from ..asgi.parser import _ProxyProtocolInfo, _ProxyProtocolInfoUnknown

MAX_UWSGI_VARS: Final = 1000

Expand All @@ -28,7 +29,7 @@ class UWSGIRequest:
uwsgi_vars: dict[str, str]
modifier1: int
modifier2: int
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
proxy_protocol_info: _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None

def __init__(self, cfg: Config, unreader: Unreader, peer_addr: _AddressType, req_number: int = 1) -> None: ...
def force_close(self) -> None: ...
Expand Down
Loading