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
4ff63bf7
Commit
4ff63bf7
authored
Sep 14, 2013
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'requestline'
parents
82f50339
5df4cef9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
gevent/pywsgi.py
gevent/pywsgi.py
+12
-7
greentest/test__pywsgi.py
greentest/test__pywsgi.py
+14
-0
No files found.
gevent/pywsgi.py
View file @
4ff63bf7
...
...
@@ -195,8 +195,12 @@ class WSGIHandler(object):
finally
:
if
self
.
socket
is
not
None
:
try
:
self
.
socket
.
_sock
.
close
()
# do not rely on garbage collection
self
.
socket
.
close
()
# read out request data to prevent error: [Errno 104] Connection reset by peer
try
:
self
.
socket
.
_sock
.
recv
(
16384
)
finally
:
self
.
socket
.
_sock
.
close
()
# do not rely on garbage collection
self
.
socket
.
close
()
except
socket
.
error
:
pass
self
.
__dict__
.
pop
(
'socket'
,
None
)
...
...
@@ -287,21 +291,22 @@ class WSGIHandler(object):
return
try
:
raw_
requestline
=
self
.
read_requestline
()
self
.
requestline
=
self
.
read_requestline
()
except
socket
.
error
:
# "Connection reset by peer" or other socket errors aren't interesting here
return
if
not
raw_
requestline
:
if
not
self
.
requestline
:
return
self
.
response_length
=
0
if
len
(
raw_
requestline
)
>=
MAX_REQUEST_LINE
:
if
len
(
self
.
requestline
)
>=
MAX_REQUEST_LINE
:
return
(
'414'
,
_REQUEST_TOO_LONG_RESPONSE
)
try
:
if
not
self
.
read_request
(
raw_requestline
):
# for compatibility with older versions of pywsgi, we pass self.requestline as an argument there
if
not
self
.
read_request
(
self
.
requestline
):
return
(
'400'
,
_BAD_REQUEST_RESPONSE
)
except
Exception
:
ex
=
sys
.
exc_info
()[
1
]
...
...
@@ -470,7 +475,7 @@ class WSGIHandler(object):
return
'%s - - [%s] "%s" %s %s %s'
%
(
client_address
or
'-'
,
now
,
self
.
requestline
,
getattr
(
self
,
'requestline'
,
''
)
,
(
getattr
(
self
,
'status'
,
None
)
or
'000'
).
split
()[
0
],
length
,
delta
)
...
...
greentest/test__pywsgi.py
View file @
4ff63bf7
...
...
@@ -1218,6 +1218,20 @@ class TestInputRaw(greentest.BaseTestCase):
i
=
self
.
make_input
(
"2
\
r
\
n
1"
,
chunked_input
=
True
)
self
.
assertRaises
(
IOError
,
i
.
readline
)
class
Test414
(
TestCase
):
@
staticmethod
def
application
(
env
,
start_response
):
raise
AssertionError
(
'should not get there'
)
def
test
(
self
):
fd
=
self
.
makefile
()
longline
=
'x'
*
20000
fd
.
write
(
'''GET /%s HTTP/1.0
\
r
\
n
Hello: world
\
r
\
n
\
r
\
n
'''
%
longline
)
read_http
(
fd
,
code
=
414
,
version
=
'1.0'
)
del
CommonTests
if
__name__
==
'__main__'
:
...
...
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