Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
e56b9eb3
Commit
e56b9eb3
authored
Aug 13, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsgi_test.py: support for chunked transfer encoding in read_http()
parent
79feea59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
greentest/wsgi_test.py
greentest/wsgi_test.py
+20
-0
No files found.
greentest/wsgi_test.py
View file @
e56b9eb3
...
...
@@ -117,6 +117,24 @@ def read_headers(fd):
return
response_line
,
headers
def
iread_chunks
(
fd
):
while
True
:
chunk_size
=
fd
.
readline
().
strip
()
try
:
chunk_size
=
int
(
chunk_size
,
16
)
except
:
print
'Failed to parse chunk size: %r'
%
chunk_size
raise
if
chunk_size
==
0
:
crlf
=
fd
.
read
(
2
)
assert
crlf
==
'
\
r
\
n
'
,
repr
(
crlf
)
break
data
=
fd
.
read
(
chunk_size
)
yield
data
crlf
=
fd
.
read
(
2
)
assert
crlf
==
'
\
r
\
n
'
,
repr
(
crlf
)
def
read_http
(
fd
):
response_line
,
headers
=
read_headers
(
fd
)
...
...
@@ -124,6 +142,8 @@ def read_http(fd):
num
=
int
(
headers
[
CONTENT_LENGTH
])
body
=
fd
.
read
(
num
)
#print body
elif
'chunked'
in
headers
.
get
(
'transfer-encoding'
,
''
):
body
=
''
.
join
(
iread_chunks
(
fd
))
else
:
body
=
None
...
...
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