def is_successful_upgrade(upgrade_response):
 if (upgrade_response.get_code() != 101):
  return False
 headers = upgrade_response.get_headers()
 (upgrade_value, _) = headers.iget('Upgrade', None)
 (connection_value, _) = headers.iget('Connection', None)
 (sec_websocket_accept_value, _) = headers.iget('Sec-WebSocket-Accept', None)
 if (upgrade_value and connection_value and sec_websocket_accept_value):
  return True
 return False

def is_successful_upgrade ( upgrade_response ) : if ( upgrade_response . get_code ( ) != 101 ) : return False headers = upgrade_response . get_headers ( ) ( upgrade_value , _ ) = headers . iget ( 'Upgrade' , None ) ( connection_value , _ ) = headers . iget ( 'Connection' , None ) ( sec_websocket_accept_value , _ ) = headers . iget ( 'Sec-WebSocket-Accept' , None ) if ( upgrade_value and connection_value and sec_websocket_accept_value ) : return True return False
match against: http/1 .