def _accept(self, event: AcceptConnection) -> bytes:
    request_headers = normed_header_dict(self._initiating_request.extra_headers)
    nonce = request_headers[b'sec-websocket-key']
    accept_token = generate_accept_token(nonce)
    headers = [(b'Upgrade', b'WebSocket'), (b'Connection', b'Upgrade'), (b'Sec-WebSocket-Accept', accept_token)]
    if (event.subprotocol is not None):
        if (event.subprotocol not in self._initiating_request.subprotocols):
            raise LocalProtocolError('unexpected subprotocol {}'.format(event.subprotocol))
        headers.append((b'Sec-WebSocket-Protocol', event.subprotocol.encode('ascii')))
    if event.extensions:
        accepts = server_extensions_handshake(self._initiating_request.extensions, event.extensions)
        if accepts:
            headers.append((b'Sec-WebSocket-Extensions', accepts))
    response = h11.InformationalResponse(status_code=101, headers=(headers + event.extra_headers))
    self._connection = Connection((ConnectionType.CLIENT if self.client else ConnectionType.SERVER), event.extensions)
    self._state = ConnectionState.OPEN
    return self._h11_connection.send(response)
def _accept(self, event: AcceptConnection) -> bytes:
    request_headers = normed_header_dict(self._initiating_request.extra_headers)
    nonce = request_headers[b'sec-websocket-key']
    accept_token = generate_accept_token(nonce)
    headers = [(b'Upgrade', b'WebSocket'), (b'Connection', b'Upgrade'), (b'Sec-WebSocket-Accept', accept_token)]
    if (event.subprotocol is not None):
        if (event.subprotocol not in self._initiating_request.subprotocols):
            raise LocalProtocolError('unexpected subprotocol {}'.format(event.subprotocol))
        headers.append((b'Sec-WebSocket-Protocol', event.subprotocol.encode('ascii')))
    if event.extensions:
        accepts = server_extensions_handshake(self._initiating_request.extensions, event.extensions)
        if accepts:
            headers.append((b'Sec-WebSocket-Extensions', accepts))
    response = h11.InformationalResponse(status_code=101, headers=(headers + event.extra_headers))
    self._connection = Connection((ConnectionType.CLIENT if self.client else ConnectionType.SERVER), event.extensions)
    self._state = ConnectionState.OPEN
    return self._h11_connection.send(response)