MCPcopy Create free account
hub / github.com/pallets/quart / accept_connection

Method accept_connection

src/quart/asgi.py:316–336  ·  view source on GitHub ↗
(
        self, send: ASGISendCallable, headers: Headers, subprotocol: str | None
    )

Source from the content-addressed store, hash-verified

314 await websocket_sent.send_async(data)
315
316 async def accept_connection(
317 self, send: ASGISendCallable, headers: Headers, subprotocol: str | None
318 ) -> None:
319 if not self._accepted:
320 message: WebsocketAcceptEvent = {
321 "headers": [],
322 "subprotocol": subprotocol,
323 "type": "websocket.accept",
324 }
325 spec_version = _convert_version(
326 self.scope.get("asgi", {}).get("spec_version", "2.0")
327 )
328 if spec_version > [2, 0]:
329 message["headers"] = encode_headers(headers)
330 elif headers:
331 warnings.warn(
332 "The ASGI Server does not support accept headers, headers not sent",
333 stacklevel=1,
334 )
335 self._accepted = True
336 await send(message)
337
338 async def close_connection(
339 self, send: ASGISendCallable, code: int, reason: str

Calls 4

_convert_versionFunction · 0.85
encode_headersFunction · 0.85
sendFunction · 0.85
getMethod · 0.45