@@ -9,6 +9,22 @@ class ParseError(Exception): ...
99class InvalidProxyLine (ParseError ): ...
1010class InvalidProxyHeader (ParseError ): ...
1111
12+ @type_check_only
13+ class _ProxyProtocolInfo (TypedDict ):
14+ proxy_protocol : Literal ["TCP4" , "TCP6" , "UDP4" , "UDP6" ]
15+ client_addr : str
16+ client_port : int
17+ proxy_addr : str
18+ proxy_port : int
19+
20+ @type_check_only
21+ class _ProxyProtocolInfoUnknown (TypedDict ):
22+ proxy_protocol : Literal ["UNKNOWN" , "LOCAL" , "UNSPEC" ]
23+ client_addr : None
24+ client_port : None
25+ proxy_addr : None
26+ proxy_port : None
27+
1228PP_V2_SIGNATURE : Final [bytes ]
1329RFC9110_6_5_1_FORBIDDEN_TRAILER : Final [frozenset [bytes ]]
1430
@@ -38,22 +54,6 @@ class UnsupportedTransferCoding(ParseError): ...
3854class InvalidChunkSize (ParseError ): ...
3955class InvalidChunkExtension (ParseError ): ...
4056
41- @type_check_only
42- class _ProxyProtocolInfo (TypedDict ):
43- proxy_protocol : Literal ["TCP4" , "TCP6" , "UDP4" , "UDP6" ]
44- client_addr : str
45- client_port : int
46- proxy_addr : str
47- proxy_port : int
48-
49- @type_check_only
50- class _ProxyProtocolInfoUnknown (TypedDict ):
51- proxy_protocol : Literal ["UNKNOWN" , "LOCAL" , "UNSPEC" ]
52- client_addr : None
53- client_port : None
54- proxy_addr : None
55- proxy_port : None
56-
5757class PythonProtocol :
5858 __slots__ = (
5959 "_on_message_begin" ,
@@ -149,7 +149,7 @@ class CallbackRequest:
149149 content_length : int
150150 chunked : bool
151151 must_close : bool
152- proxy_protocol_info : dict [ str , str | int | None ] | None # TODO: Use TypedDict
152+ proxy_protocol_info : _ProxyProtocolInfo | _ProxyProtocolInfoUnknown | None
153153
154154 def __init__ (self ) -> None : ...
155155 @classmethod
0 commit comments