mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-15 00:00:39 -04:00
http/1.1 fix: close connection even if the server does not respect connectionn: close in request
This commit is contained in:
parent
e27301013d
commit
1e05cdbe62
@ -181,7 +181,7 @@ module HTTPX
|
||||
if response.is_a?(ErrorResponse)
|
||||
disable
|
||||
else
|
||||
manage_connection(response)
|
||||
manage_connection(request, response)
|
||||
end
|
||||
|
||||
if exhausted?
|
||||
@ -224,7 +224,7 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def manage_connection(response)
|
||||
def manage_connection(request, response)
|
||||
connection = response.headers["connection"]
|
||||
case connection
|
||||
when /keep-alive/i
|
||||
@ -254,7 +254,7 @@ module HTTPX
|
||||
disable
|
||||
when nil
|
||||
# In HTTP/1.1, it's keep alive by default
|
||||
return if response.version == "1.1"
|
||||
return if response.version == "1.1" && request.headers["connection"] != "close"
|
||||
|
||||
disable
|
||||
end
|
||||
|
@ -59,13 +59,13 @@ module HTTPX
|
||||
|
||||
def initialize: (Buffer, options) -> untyped
|
||||
|
||||
def manage_connection: (Response) -> void
|
||||
def manage_connection: (Request request, Response response) -> void
|
||||
|
||||
def disable: () -> void
|
||||
|
||||
def disable_pipelining: () -> void
|
||||
|
||||
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
||||
def set_protocol_headers: (Request request) -> _Each[[String, String]]
|
||||
|
||||
def handle: (Request request) -> void
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user