class HTTPI::Adapter::NetHTTPPersistent
HTTPI::Adapter::NetHTTPPersistent
¶ ↑
Adapter
for the Net::HTTP::Persistent client. docs.seattlerb.org/net-http-persistent/Net/HTTP/Persistent.html
Private Instance Methods
create_client()
click to toggle source
# File lib/httpi/adapter/net_http_persistent.rb, line 14 def create_client if Gem::Version.new(Net::HTTP::Persistent::VERSION) >= Gem::Version.new('3.0.0') Net::HTTP::Persistent.new name: thread_key else Net::HTTP::Persistent.new thread_key end end
do_request(type, &requester)
click to toggle source
# File lib/httpi/adapter/net_http_persistent.rb, line 26 def do_request(type, &requester) setup response = requester.call @client, request_client(type) respond_with(response) end
perform(http, http_request, &on_body)
click to toggle source
# File lib/httpi/adapter/net_http_persistent.rb, line 22 def perform(http, http_request, &on_body) http.request @request.url, http_request, &on_body end
setup_client()
click to toggle source
# File lib/httpi/adapter/net_http_persistent.rb, line 32 def setup_client if @request.auth.ntlm? raise NotSupportedError, "Net::HTTP-Persistent does not support NTLM authentication" end @client.open_timeout = @request.open_timeout if @request.open_timeout @client.read_timeout = @request.read_timeout if @request.read_timeout raise NotSupportedError, "Net::HTTP::Persistent does not support write_timeout" if @request.write_timeout end
thread_key()
click to toggle source
# File lib/httpi/adapter/net_http_persistent.rb, line 42 def thread_key @request.url.host.split(/\W/).reject{|p|p == ""}.join('-') end