aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/websockets/protocol.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-05-28 22:17:02 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-05-28 22:17:02 +0200
commite5038c9ab7a6718e7a3408a43549231929c7beb9 (patch)
treeba9255d148fa325a0adf0b891436cb5559b1cc1d /netlib/websockets/protocol.py
parente1cc91900f95c82e15d39cac1e0b9fa8b265d391 (diff)
downloadmitmproxy-e5038c9ab7a6718e7a3408a43549231929c7beb9.tar.gz
mitmproxy-e5038c9ab7a6718e7a3408a43549231929c7beb9.tar.bz2
mitmproxy-e5038c9ab7a6718e7a3408a43549231929c7beb9.zip
netlib: fix most flake8 offenses
Diffstat (limited to 'netlib/websockets/protocol.py')
-rw-r--r--netlib/websockets/protocol.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/netlib/websockets/protocol.py b/netlib/websockets/protocol.py
index 940132ad..101d5484 100644
--- a/netlib/websockets/protocol.py
+++ b/netlib/websockets/protocol.py
@@ -1,18 +1,18 @@
+"""
+Colleciton of utility functions that implement small portions of the RFC6455
+WebSockets Protocol Useful for building WebSocket clients and servers.
+Emphassis is on readabilty, simplicity and modularity, not performance or
+completeness
+This is a work in progress and does not yet contain all the utilites need to
+create fully complient client/servers #
+Spec: https://tools.ietf.org/html/rfc6455
-# Colleciton of utility functions that implement small portions of the RFC6455
-# WebSockets Protocol Useful for building WebSocket clients and servers.
-#
-# Emphassis is on readabilty, simplicity and modularity, not performance or
-# completeness
-#
-# This is a work in progress and does not yet contain all the utilites need to
-# create fully complient client/servers #
-# Spec: https://tools.ietf.org/html/rfc6455
+The magic sha that websocket servers must know to prove they understand
+RFC6455
+"""
-# The magic sha that websocket servers must know to prove they understand
-# RFC6455
from __future__ import absolute_import
import base64
import hashlib
@@ -94,21 +94,18 @@ class WebsocketsProtocol(object):
upgrade="websocket"
)
-
@classmethod
def check_client_handshake(self, headers):
if headers.get("upgrade") != "websocket":
return
return headers.get("sec-websocket-key")
-
@classmethod
def check_server_handshake(self, headers):
if headers.get("upgrade") != "websocket":
return
return headers.get("sec-websocket-accept")
-
@classmethod
def create_server_nonce(self, client_nonce):
return base64.b64encode(hashlib.sha1(client_nonce + websockets_magic).digest())