@@ -214,6 +214,7 @@ def parse(
214214 read_exact : Callable [[int ], Generator [None , None , bytes ]],
215215 read_to_eof : Callable [[int ], Generator [None , None , bytes ]],
216216 include_body : bool = True ,
217+ allow_http10 : bool = False ,
217218 ) -> Generator [None , None , Response ]:
218219 """
219220 Parse a WebSocket handshake response.
@@ -249,10 +250,17 @@ def parse(
249250 protocol , raw_status_code , raw_reason = status_line .split (b" " , 2 )
250251 except ValueError : # not enough values to unpack (expected 3, got 1-2)
251252 raise ValueError (f"invalid HTTP status line: { d (status_line )} " ) from None
252- if protocol != b"HTTP/1.1" :
253- raise ValueError (
254- f"unsupported protocol; expected HTTP/1.1: { d (status_line )} "
255- )
253+ if allow_http10 : # some proxies still use HTTP/1.0
254+ if protocol not in [b"HTTP/1.1" , b"HTTP/1.0" ]:
255+ raise ValueError (
256+ f"unsupported protocol; expected HTTP/1.1 or HTTP/1.0: "
257+ f"{ d (status_line )} "
258+ )
259+ else :
260+ if protocol != b"HTTP/1.1" :
261+ raise ValueError (
262+ f"unsupported protocol; expected HTTP/1.1: { d (status_line )} "
263+ )
256264 try :
257265 status_code = int (raw_status_code )
258266 except ValueError : # invalid literal for int() with base 10
0 commit comments