Check if request is a WebSocket upgrade. Per RFC 6455 Section 4.1, the opening handshake requires: - HTTP method MUST be GET - Upgrade header MUST be "websocket" (case-insensitive) - Connection header MUST contain "Upgrade"
(self, request)
| 890 | await request.drain_body() |
| 891 | |
| 892 | def _is_websocket_upgrade(self, request): |
| 893 | """Check if request is a WebSocket upgrade. |
| 894 | |
| 895 | Per RFC 6455 Section 4.1, the opening handshake requires: |
| 896 | - HTTP method MUST be GET |
| 897 | - Upgrade header MUST be "websocket" (case-insensitive) |
| 898 | - Connection header MUST contain "Upgrade" |
| 899 | """ |
| 900 | # RFC 6455: The method of the request MUST be GET |
| 901 | if request.method != "GET": |
| 902 | return False |
| 903 | |
| 904 | upgrade = None |
| 905 | connection = None |
| 906 | for name, value in request.headers: |
| 907 | if name == "UPGRADE": |
| 908 | upgrade = value.lower() |
| 909 | elif name == "CONNECTION": |
| 910 | connection = value.lower() |
| 911 | return upgrade == "websocket" and connection and "upgrade" in connection |
| 912 | |
| 913 | async def _handle_websocket(self, request, sockname, peername): |
| 914 | """Handle WebSocket upgrade request.""" |
no outgoing calls