Commit f281e9ab authored by Taddeüs Kroes's avatar Taddeüs Kroes

Worked on extensions

parent 9d12f4e5
...@@ -8,3 +8,4 @@ from frame import Frame, ControlFrame, OPCODE_CONTINUATION, OPCODE_TEXT, \ ...@@ -8,3 +8,4 @@ from frame import Frame, ControlFrame, OPCODE_CONTINUATION, OPCODE_TEXT, \
from connection import Connection from connection import Connection
from message import Message, TextMessage, BinaryMessage from message import Message, TextMessage, BinaryMessage
from errors import SocketClosed from errors import SocketClosed
from extension import Extension, DeflateFrame
...@@ -21,6 +21,9 @@ class Extension(object): ...@@ -21,6 +21,9 @@ class Extension(object):
setattr(self, param, value) setattr(self, param, value)
def client_params(self, frame):
return {}
def hook_send(self, frame): def hook_send(self, frame):
return frame return frame
...@@ -28,12 +31,13 @@ class Extension(object): ...@@ -28,12 +31,13 @@ class Extension(object):
return frame return frame
class Deflate(Extension): class DeflateFrame(Extension):
name = 'deflate-frame'
rsv1 = True rsv1 = True
parameters = ['max_window_bits', 'no_context_takeover'] parameters = ['max_window_bits', 'no_context_takeover']
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(Deflate, self).__init__(**kwargs) super(DeflateFrame, self).__init__(**kwargs)
self.max_window_bits = int(self.max_window_bits) self.max_window_bits = int(self.max_window_bits)
def hook_send(self, frame): def hook_send(self, frame):
...@@ -54,6 +58,9 @@ class Deflate(Extension): ...@@ -54,6 +58,9 @@ class Deflate(Extension):
return frame return frame
def client_params(self):
raise NotImplementedError # TODO
def encode(self, data): def encode(self, data):
raise NotImplementedError # TODO raise NotImplementedError # TODO
...@@ -61,7 +68,7 @@ class Deflate(Extension): ...@@ -61,7 +68,7 @@ class Deflate(Extension):
raise NotImplementedError # TODO raise NotImplementedError # TODO
def filter_compatible(extensions): def filter_extensions(extensions):
""" """
Remove extensions that use conflicting rsv bits and/or opcodes, with the Remove extensions that use conflicting rsv bits and/or opcodes, with the
first options being most preferable. first options being most preferable.
......
...@@ -41,7 +41,7 @@ class websocket(object): ...@@ -41,7 +41,7 @@ class websocket(object):
`protocols` is a list of supported protocol names. `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 `origin` (for client sockets) is the value for the "Origin" header sent
in a client handshake . in a client handshake .
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment