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

Method respond

src/websockets/asyncio/server.py:93–112  ·  view source on GitHub ↗

Create a plain text HTTP response. ``process_request`` and ``process_response`` may call this method to return an HTTP response instead of performing the WebSocket opening handshake. You can modify the response before returning it, for example by changing

(self, status: StatusLike, text: str)

Source from the content-addressed store, hash-verified

91 self.handler_kwargs: Mapping[str, Any] # see route()
92
93 def respond(self, status: StatusLike, text: str) -> Response:
94 """
95 Create a plain text HTTP response.
96
97 ``process_request`` and ``process_response`` may call this method to
98 return an HTTP response instead of performing the WebSocket opening
99 handshake.
100
101 You can modify the response before returning it, for example by changing
102 HTTP headers.
103
104 Args:
105 status: HTTP status code.
106 text: HTTP response body; it will be encoded to UTF-8.
107
108 Returns:
109 HTTP response to send to the client.
110
111 """
112 return self.protocol.reject(status, text)
113
114 async def handshake(
115 self,

Callers 3

process_requestFunction · 0.45
redirectMethod · 0.45
not_foundMethod · 0.45

Calls 1

rejectMethod · 0.45

Tested by

no test coverage detected