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

Method send_response

src/websockets/server.py:510–542  ·  view source on GitHub ↗

Send a handshake response to the client. Args: response: WebSocket handshake response event to send.

(self, response: Response)

Source from the content-addressed store, hash-verified

508 return Response(status.value, status.phrase, headers, body)
509
510 def send_response(self, response: Response) -> None:
511 """
512 Send a handshake response to the client.
513
514 Args:
515 response: WebSocket handshake response event to send.
516
517 """
518 if self.debug:
519 code, phrase = response.status_code, response.reason_phrase
520 self.logger.debug("> HTTP/1.1 %d %s", code, phrase)
521 for key, value in response.headers.raw_items():
522 self.logger.debug("> %s: %s", key, value)
523 if response.body:
524 self.logger.debug("> [body] (%d bytes)", len(response.body))
525
526 self.writes.append(response.serialize())
527
528 if response.status_code == 101:
529 assert self.state is CONNECTING
530 self.state = OPEN
531 self.logger.info("connection open")
532
533 else:
534 self.logger.info(
535 "connection rejected (%d %s)",
536 response.status_code,
537 response.reason_phrase,
538 )
539
540 self.send_eof()
541 self.parser = self.discard()
542 next(self.parser) # start coroutine
543
544 def parse(self) -> Generator[None]:
545 if self.state is CONNECTING:

Calls 5

raw_itemsMethod · 0.80
appendMethod · 0.80
send_eofMethod · 0.80
serializeMethod · 0.45
discardMethod · 0.45