lib/httpx/connection/http1.rb in httpx-0.14.2 vs lib/httpx/connection/http1.rb in httpx-0.14.3

- old
+ new

@@ -78,11 +78,10 @@ concurrent_requests_limit = [@max_concurrent_requests, requests_limit].min @requests.each_with_index do |request, idx| break if idx >= concurrent_requests_limit next if request.state == :done - request.headers["connection"] ||= request.options.persistent || idx < requests_limit - 1 ? "keep-alive" : "close" handle(request) end end # HTTP Parser callbacks @@ -257,12 +256,18 @@ if !request.headers.key?("content-length") && request.body.bytesize == Float::INFINITY request.chunk! end + connection = if request.options.persistent || request != @requests[-1] + "keep-alive" + else + "close" + end + { "host" => (request.headers["host"] || request.authority), - "connection" => (request.headers["connection"] || (request.options.persistent ? "keep-alive" : "close")), + "connection" => connection, } end def headline_uri(request) request.path