MCPcopy Index your code
hub / github.com/python-websockets/websockets / read_connect_response

Function read_connect_response

src/websockets/sync/client.py:480–511  ·  view source on GitHub ↗
(sock: socket.socket, deadline: Deadline)

Source from the content-addressed store, hash-verified

478
479
480def read_connect_response(sock: socket.socket, deadline: Deadline) -> Response:
481 reader = StreamReader()
482 parser = Response.parse(
483 reader.read_line,
484 reader.read_exact,
485 reader.read_to_eof,
486 proxy=True,
487 )
488 try:
489 while True:
490 sock.settimeout(deadline.timeout())
491 data = sock.recv(4096)
492 if data:
493 reader.feed_data(data)
494 else:
495 reader.feed_eof()
496 next(parser)
497 except StopIteration as exc:
498 assert isinstance(exc.value, Response) # help mypy
499 response = exc.value
500 if 200 <= response.status_code < 300:
501 return response
502 else:
503 raise InvalidProxyStatus(response)
504 except socket.timeout:
505 raise TimeoutError("timed out while connecting to HTTP proxy")
506 except Exception as exc:
507 raise InvalidProxyMessage(
508 "did not receive a valid HTTP response from proxy"
509 ) from exc
510 finally:
511 sock.settimeout(None)
512
513
514def connect_http_proxy(

Callers 1

connect_http_proxyFunction · 0.85

Calls 8

feed_dataMethod · 0.95
feed_eofMethod · 0.95
StreamReaderClass · 0.85
InvalidProxyStatusClass · 0.85
InvalidProxyMessageClass · 0.85
timeoutMethod · 0.80
parseMethod · 0.45
recvMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…