Closed mislav closed 12 years ago
I'm making 2 requests to the same local server, each instantiating a new Persistent object.
require 'net/http/persistent' require 'uri' def req uri, timeout = false uri = URI(uri.to_s) http = Net::HTTP::Persistent.new 'Faraday' request = Net::HTTPGenericRequest.new 'GET', false, true, uri.request_uri http.read_timeout = timeout if timeout != false http.request uri, request end # 1st GET request with no timeout req('http://127.0.0.1:4567/echo', nil) begin # "/slow" is a resource that sleeps for 10 seconds p req('http://127.0.0.1:4567/slow', 1) abort "this shouldn't happen!" rescue Net::HTTP::Persistent::Error puts $!.message puts "Good." end
Currently read_timeout is only set when the connection is started. I'll rearrange some things to make it settable per-request.
Oops, that should say "request"
I'm making 2 requests to the same local server, each instantiating a new Persistent object.