Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c12fef9a
Commit
c12fef9a
authored
Feb 18, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26309: Shut down socketserver request if verify_request() is false
Patch by Aviv Palivoda.
parent
8f0432ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
Lib/socketserver.py
Lib/socketserver.py
+2
-0
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+24
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/socketserver.py
View file @
c12fef9a
...
...
@@ -319,6 +319,8 @@ class BaseServer:
except
:
self
.
handle_error
(
request
,
client_address
)
self
.
shutdown_request
(
request
)
else
:
self
.
shutdown_request
(
request
)
def
handle_timeout
(
self
):
"""Called if no new request arrives within self.timeout.
...
...
Lib/test/test_socketserver.py
View file @
c12fef9a
...
...
@@ -280,6 +280,30 @@ class SocketServerTest(unittest.TestCase):
socketserver
.
TCPServer
((
HOST
,
-
1
),
socketserver
.
StreamRequestHandler
)
def
test_shutdown_request_called_if_verify_request_false
(
self
):
# Issue #26309: BaseServer should call shutdown_request even if
# verify_request is False
shutdown_called
=
False
class
MyServer
(
socketserver
.
TCPServer
):
def
verify_request
(
self
,
request
,
client_address
):
return
False
def
shutdown_request
(
self
,
request
):
nonlocal
shutdown_called
shutdown_called
=
True
super
().
shutdown_request
(
request
)
def
connect_to_server
(
proto
,
addr
):
s
=
socket
.
socket
(
proto
,
socket
.
SOCK_STREAM
)
s
.
connect
(
addr
)
s
.
close
()
self
.
run_server
(
MyServer
,
socketserver
.
StreamRequestHandler
,
connect_to_server
)
self
.
assertEqual
(
shutdown_called
,
True
)
class
MiscTestCase
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
c12fef9a
...
...
@@ -76,6 +76,10 @@ Core and Builtins
Library
-------
- Issue #26309: In the "socketserver" module, shut down the request (closing
the connected socket) when verify_request() returns false. Patch by Aviv
Palivoda.
- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates.
- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
...
...
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