Taddeus Kroes 12 жил өмнө
parent
commit
f281e9abf3
3 өөрчлөгдсөн 12 нэмэгдсэн , 4 устгасан
  1. 1 0
      __init__.py
  2. 10 3
      extension.py
  3. 1 1
      websocket.py

+ 1 - 0
__init__.py

@@ -8,3 +8,4 @@ from frame import Frame, ControlFrame, OPCODE_CONTINUATION, OPCODE_TEXT, \
 from connection import Connection
 from message import Message, TextMessage, BinaryMessage
 from errors import SocketClosed
+from extension import Extension, DeflateFrame

+ 10 - 3
extension.py

@@ -21,6 +21,9 @@ class Extension(object):
 
             setattr(self, param, value)
 
+    def client_params(self, frame):
+        return {}
+
     def hook_send(self, frame):
         return frame
 
@@ -28,12 +31,13 @@ class Extension(object):
         return frame
 
 
-class Deflate(Extension):
+class DeflateFrame(Extension):
+    name = 'deflate-frame'
     rsv1 = True
     parameters = ['max_window_bits', 'no_context_takeover']
 
     def __init__(self, **kwargs):
-        super(Deflate, self).__init__(**kwargs)
+        super(DeflateFrame, self).__init__(**kwargs)
         self.max_window_bits = int(self.max_window_bits)
 
     def hook_send(self, frame):
@@ -54,6 +58,9 @@ class Deflate(Extension):
 
         return frame
 
+    def client_params(self):
+        raise NotImplementedError  # TODO
+
     def encode(self, data):
         raise NotImplementedError  # TODO
 
@@ -61,7 +68,7 @@ class Deflate(Extension):
         raise NotImplementedError  # TODO
 
 
-def filter_compatible(extensions):
+def filter_extensions(extensions):
     """
     Remove extensions that use conflicting rsv bits and/or opcodes, with the
     first options being most preferable.

+ 1 - 1
websocket.py

@@ -41,7 +41,7 @@ class websocket(object):
 
         `protocols` is a list of supported protocol names.
 
-        `extensions` is a list of supported extensions.
+        `extensions` is a list of supported extension classes.
 
         `origin` (for client sockets) is the value for the "Origin" header sent
         in a client handshake .