Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.4:ARM
python-cheroot.33628
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.33628
From 18c7bad7cef259551ab5f36f01ffa9d50440327a 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 08590b10..d3512254 100644 --- a/cheroot/server.py +++ b/cheroot/server.py @@ -1172,6 +1172,11 @@ class HTTPRequest: 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