Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

connections now properly persist across multiple requests (when possi…

…ble)
  • Loading branch information...
commit 36ea2be1153f87c57670b7d5bdd76f21e60a3948 1 parent 23ce06f
@dtomasiewicz authored
Showing with 14 additions and 10 deletions.
  1. +14 −10 r_browse/browser.rb
View
24 r_browse/browser.rb
@@ -64,14 +64,7 @@ def request(klass, url, params = {})
end
url.path = '/' if url.path == ''
- http = conn url.host, (url.port || DEFAULT_PORTS[url.scheme])
- if url.scheme == 'https'
- http.use_ssl = true
- http.ssl_version = ssl_version
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE # unsafe
- else
- http.use_ssl = false
- end
+ http = conn url
# create request object
req = klass.new "#{url.path}#{'?'+url.query if url.query}"
@@ -128,8 +121,19 @@ def with_referer(ref, &block)
@referer = old_ref
end
- def conn(host, port)
- @conns[[host, port]] ||= Net::HTTP.new host, port
+ def conn(url)
+ port = url.port || DEFAULT_PORTS[url.scheme]
+ id = [url.host, port, url.scheme]
+ unless (c = @conns[id]) && c.started?
+ c = @conns[id] = Net::HTTP.new(url.host, port)
+ if url.scheme == 'https'
+ c.use_ssl = true
+ c.ssl_version = ssl_version
+ c.verify_mode = OpenSSL::SSL::VERIFY_NONE # unsafe
+ end
+ c.start
+ end
+ c
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.