Commit d4b1c5d
Changed files (3)
lib
net
hippie
test
net
lib/net/hippie/client.rb
@@ -67,7 +67,7 @@ module Net
def http_for(uri)
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 30
- http.use_ssl = uri.is_a?(URI::HTTPS)
+ http.use_ssl = uri.scheme == "https"
http.verify_mode = verify_mode
http.set_debug_output(Net::Hippie.logger)
apply_client_tls_to(http)
@@ -76,7 +76,7 @@ module Net
def request_for(type, uri, headers: {}, body: {})
final_headers = default_headers.merge(headers)
- type.new(uri, final_headers).tap do |x|
+ type.new(uri.to_s, final_headers).tap do |x|
x.body = mapper.map_from(final_headers, body) unless body.empty?
end
end
lib/net/hippie/version.rb
@@ -2,6 +2,6 @@
module Net
module Hippie
- VERSION = '0.1.7'
+ VERSION = '0.1.8'
end
end
test/net/client_test.rb
@@ -25,6 +25,15 @@ class ClientTest < Minitest::Test
end
end
+ def test_get_with_generic_uri
+ VCR.use_cassette('get_breaches') do
+ uri = URI::Generic.build(host: 'haveibeenpwned.com', scheme: 'https', path: '/api/breaches', port: 443)
+ response = subject.get(uri)
+ refute_nil response
+ assert_equal(283, JSON.parse(response.body).count)
+ end
+ end
+
def test_get_with_block_syntax
VCR.use_cassette('get_breaches') do
uri = URI.parse('https://haveibeenpwned.com/api/breaches')