Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15
python-cheroot.14999
0001-Avoid-race-condition-on-persistent-HTTP-co...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Avoid-race-condition-on-persistent-HTTP-connections.patch of Package python-cheroot.14999
From 404144c9e35c0a2f8987f84dea0460072e854c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= <psuarezhernandez@suse.com> Date: Wed, 6 May 2020 14:04:48 +0100 Subject: [PATCH] Avoid race condition on persistent HTTP connections Add a HTTP "Keep-Alive" header with "timeout" on the HTTP response to avoid a race condition on persistent HTTP connections when the HTTP client reuses a connection after the "socket.timeout" exception triggered on the HTTPServer but before the FIN packet is produced. When this happens, the client gets a "connection reset by peer" after writting the request. This commit makes a HTTP client to know about this "Keep-Alive" idle timeout by exposing it on the HTTP "Keep-Alive" response header, so the connection won't be reused if it was "idle" for that "timeout" after the last request response. --- cheroot/server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheroot/server.py b/cheroot/server.py index bbd6a653..328e5f21 100644 --- a/cheroot/server.py +++ b/cheroot/server.py @@ -858,6 +858,11 @@ class HTTPRequest(object): if not self.close_connection: self.outheaders.append((b'Connection', b'Keep-Alive')) + self.outheaders.append(( + b'Keep-Alive', + "timeout={}".format(self.server.timeout).encode('ISO-8859-1'), + )) + if (not self.close_connection) and (not self.chunked_read): # Read any remaining request body data on the socket. # "If an origin server receives a request that does not include an -- 2.23.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor