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
d17b2ebb
Commit
d17b2ebb
authored
Aug 25, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First attempt at inflate/deflate
parent
2963b26e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
extension.py
extension.py
+30
-3
No files found.
extension.py
View file @
d17b2ebb
import
zlib
class
Extension
(
object
):
class
Extension
(
object
):
name
=
''
name
=
''
rsv1
=
False
rsv1
=
False
...
@@ -58,7 +61,7 @@ class DeflateFrame(Extension):
...
@@ -58,7 +61,7 @@ class DeflateFrame(Extension):
name
=
'deflate-frame'
name
=
'deflate-frame'
rsv1
=
True
rsv1
=
True
# FIXME: is 32768 (below) correct?
# FIXME: is 32768 (below) correct?
defaults
=
{
'max_window_bits'
:
32768
,
'no_context_takeover'
:
True
}
defaults
=
{
'max_window_bits'
:
15
,
'no_context_takeover'
:
True
}
def
__init__
(
self
,
defaults
=
{},
request
=
{}):
def
__init__
(
self
,
defaults
=
{},
request
=
{}):
Extension
.
__init__
(
self
,
defaults
,
request
)
Extension
.
__init__
(
self
,
defaults
,
request
)
...
@@ -75,6 +78,22 @@ class DeflateFrame(Extension):
...
@@ -75,6 +78,22 @@ class DeflateFrame(Extension):
raise
ValueError
(
'"no_context_takeover" must have no value'
)
raise
ValueError
(
'"no_context_takeover" must have no value'
)
class
Hook
(
Extension
.
Hook
):
class
Hook
(
Extension
.
Hook
):
def
__init__
(
self
,
**
kwargs
):
Extension
.
Hook
.
__init__
(
**
kwargs
)
other_wbits
=
self
.
request
.
get
(
'max_window_bits'
,
15
)
# Don't request default value of max_window_bits
if
'max_window_bits'
in
self
.
request
and
other_wbits
==
15
:
del
self
.
request
[
'max_window_bits'
]
if
not
self
.
no_context_takeover
:
self
.
com
=
zlib
.
compressobj
(
zlib
.
Z_DEFAULT_COMPRESSION
,
zlib
.
DEFLATED
,
self
.
max_window_bits
)
self
.
dec
=
zlib
.
decompressobj
(
other_wbits
)
def
send
(
self
,
frame
):
def
send
(
self
,
frame
):
if
not
frame
.
rsv1
:
if
not
frame
.
rsv1
:
frame
.
rsv1
=
True
frame
.
rsv1
=
True
...
@@ -90,10 +109,18 @@ class DeflateFrame(Extension):
...
@@ -90,10 +109,18 @@ class DeflateFrame(Extension):
return
frame
return
frame
def
deflate
(
self
,
data
):
def
deflate
(
self
,
data
):
raise
NotImplementedError
# TODO
if
self
.
no_context_takeover
:
if
self
.
max_window_bits
==
15
:
return
zlib
.
compress
(
data
)
self
.
com
=
zlib
.
compressobj
(
zlib
.
Z_DEFAULT_COMPRESSION
,
zlib
.
DEFLATED
,
self
.
max_window_bits
)
return
self
.
com
.
compress
(
data
)
def
inflate
(
self
,
data
):
def
inflate
(
self
,
data
):
r
aise
NotImplementedError
# TODO
r
eturn
self
.
dec
.
decompress
(
data
)
class
Multiplex
(
Extension
):
class
Multiplex
(
Extension
):
...
...
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