Commit 8db0a06c authored by Taddeüs Kroes's avatar Taddeüs Kroes

Fixed bug where default extension parameters were ignored

parent 4388fc5c
...@@ -23,6 +23,12 @@ class Extension(object): ...@@ -23,6 +23,12 @@ class Extension(object):
return '<Extension "%s" defaults=%s request=%s>' \ return '<Extension "%s" defaults=%s request=%s>' \
% (self.name, self.defaults, self.request) % (self.name, self.defaults, self.request)
def create_hook(self, **kwargs):
params = {}
params.update(self.defaults)
params.update(kwargs)
return self.Hook(**params)
class Hook: class Hook:
def __init__(self, **kwargs): def __init__(self, **kwargs):
for param, value in kwargs.iteritems(): for param, value in kwargs.iteritems():
......
...@@ -154,7 +154,7 @@ class ServerHandshake(Handshake): ...@@ -154,7 +154,7 @@ class ServerHandshake(Handshake):
self.wsock.extensions = filter_extensions(extensions) self.wsock.extensions = filter_extensions(extensions)
for ext, params in zip(self.wsock.extensions, all_params): for ext, params in zip(self.wsock.extensions, all_params):
hook = ext.Hook(**params) hook = ext.create_hook(**params)
self.wsock.add_hook(send=hook.send, recv=hook.recv) self.wsock.add_hook(send=hook.send, recv=hook.recv)
else: else:
self.wsock.extensions = [] self.wsock.extensions = []
...@@ -249,7 +249,7 @@ class ClientHandshake(Handshake): ...@@ -249,7 +249,7 @@ class ClientHandshake(Handshake):
raise HandshakeError('server handshake contains ' raise HandshakeError('server handshake contains '
'unsupported extension "%s"' % name) 'unsupported extension "%s"' % name)
hook = supported_ext[name].Hook(**params) hook = supported_ext[name].create_hook(**params)
self.wsock.extensions.append(supported_ext[name]) self.wsock.extensions.append(supported_ext[name])
self.wsock.add_hook(send=hook.send, recv=hook.recv) self.wsock.add_hook(send=hook.send, recv=hook.recv)
......
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