Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wrong_build_response(headers, key):
return build_response(headers, "42")
self.status_int = 101
http_1_1 = environ['SERVER_PROTOCOL'] == 'HTTP/1.1'
def get_header(k):
key_map = {k.upper(): k for k in environ}
return environ[key_map['HTTP_' + k.upper().replace('-', '_')]]
key = websockets.handshake.check_request(get_header)
if not http_1_1 or key is None:
self.status_int = 400
self.content = "Invalid WebSocket handshake.\n"
else:
set_header = self.headers.__setitem__
websockets.handshake.build_response(set_header, key)
self.app_iter = HandshakeInterator(self.app_iter)
self.app_iter.close = switch_protocols
def __init__(self, environ, switch_protocols):
super().__init__()
http_1_1 = environ['SERVER_PROTOCOL'] == 'HTTP/1.1'
get_header = lambda k: environ['HTTP_' + k.upper().replace('-', '_')]
key = handshake.check_request(get_header)
if not http_1_1 or key is None:
self.status_code = 400
self.content = "Invalid WebSocket handshake.\n"
else:
self._headers = {} # Reset headers (private API!)
set_header = self.__setitem__
handshake.build_response(set_header, key)
self.close = switch_protocols