Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wspy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
wspy
Commits
6efb8807
Commit
6efb8807
authored
Aug 19, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some comments + input checking + template for multiplex extension
parent
a400500e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
12 deletions
+63
-12
__init__.py
__init__.py
+1
-1
extension.py
extension.py
+62
-11
No files found.
__init__.py
View file @
6efb8807
...
...
@@ -8,4 +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
,
HandshakeError
,
PingError
,
SSLError
from
extension
import
Extension
,
DeflateFrame
from
extension
import
Extension
,
DeflateFrame
,
Multiplex
extension.py
View file @
6efb8807
...
...
@@ -15,7 +15,7 @@ class Extension(object):
for
param
,
value
in
kwargs
.
items
():
if
param
not
in
self
.
parameters
:
raise
HandshakeError
(
'
invali
d parameter "%s"'
%
param
)
raise
HandshakeError
(
'
unrecognize
d parameter "%s"'
%
param
)
if
value
is
None
:
value
=
True
...
...
@@ -42,42 +42,93 @@ class Extension(object):
class
DeflateFrame
(
Extension
):
"""
This is an implementation of the "deflate-frame" extension, as defined by
http://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate-06.
Supported parameters are:
- max_window_size: maximum size for the LZ77 sliding window.
- no_context_takeover: disallows usage of LZ77 sliding window from
previously built frames for the current frame.
Note that the deflate and inflate hooks modify the RSV1 bit and payload of
existing `Frame` objects.
"""
name
=
'deflate-frame'
rsv1
=
True
parameters
=
[
'max_window_bits'
,
'no_context_takeover'
]
# FIXME: is this correct?
default_max_window_bits
=
32768
def
__init__
(
self
,
**
kwargs
):
super
(
DeflateFrame
,
self
).
__init__
(
**
kwargs
)
if
self
.
max_window_bits
is
None
:
# FIXME: is this correct? None may actually be a better value
self
.
max_window_bits
=
0
self
.
max_window_bits
=
self
.
default_max_window_bits
elif
not
isinstance
(
self
.
max_window_bits
,
int
):
raise
HandshakeError
(
'"max_window_bits" must be an integer'
)
elif
self
.
max_window_bits
>
32768
:
raise
HandshakeError
(
'"max_window_bits" may not be larger than '
'32768'
)
if
self
.
no_context_takeover
is
None
:
self
.
no_context_takeover
=
False
elif
self
.
no_context_takeover
is
not
True
:
raise
HandshakeError
(
'"no_context_takeover" must have no value'
)
def
hook_send
(
self
,
frame
):
# FIXME: original `frame` is modified, maybe it should be copied?
if
not
frame
.
rsv1
:
frame
.
rsv1
=
True
frame
.
payload
=
self
.
encod
e
(
frame
.
payload
)
frame
.
payload
=
self
.
deflat
e
(
frame
.
payload
)
return
frame
def
hook_recv
(
self
,
frame
):
# FIXME: original `frame` is modified, maybe it should be copied?
if
frame
.
rsv1
:
frame
.
rsv1
=
False
frame
.
payload
=
self
.
decod
e
(
frame
.
payload
)
frame
.
payload
=
self
.
inflat
e
(
frame
.
payload
)
return
frame
def
header_params
(
self
):
raise
NotImplementedError
# TODO
def
encode
(
self
,
data
):
def
deflate
(
self
,
data
):
raise
NotImplementedError
# TODO
def
inflate
(
self
,
data
):
raise
NotImplementedError
# TODO
class
Multiplex
(
Extension
):
"""
This is an implementation of the "mux" extension, as defined by
http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-11.
Supported parameters are:
- quota: TODO
"""
name
=
'mux'
rsv1
=
True
# FIXME
rsv2
=
True
# FIXME
rsv3
=
True
# FIXME
parameters
=
[
'quota'
]
def
__init__
(
self
,
**
kwargs
):
super
(
Multiplex
,
self
).
__init__
(
**
kwargs
)
# TODO: check "quota" value
def
hook_send
(
self
,
frame
):
raise
NotImplementedError
# TODO
def
hook_recv
(
self
,
frame
):
raise
NotImplementedError
# TODO
def
decode
(
self
,
data
):
def
header_params
(
self
):
raise
NotImplementedError
# TODO
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment