diff options
| author | mokha <mokha@cisco.com> | 2018-05-24 16:27:43 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2018-05-24 16:28:01 -0600 |
| commit | d4b1c5d81bcba19c1092f720b5bd523600c99b3c (patch) | |
| tree | 44dec2a83dadf0f8bded57a785589c3a4d359d3a | |
| parent | 08a3bebc663ca31c9f15e6698c78262a94ecae2d (diff) | |
add support for URI::Generic.
| -rw-r--r-- | lib/net/hippie/client.rb | 4 | ||||
| -rw-r--r-- | lib/net/hippie/version.rb | 2 | ||||
| -rw-r--r-- | test/net/client_test.rb | 9 |
3 files changed, 12 insertions, 3 deletions
diff --git a/lib/net/hippie/client.rb b/lib/net/hippie/client.rb index d6638a1..867d79e 100644 --- a/lib/net/hippie/client.rb +++ b/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 diff --git a/lib/net/hippie/version.rb b/lib/net/hippie/version.rb index 2a1a084..3d28817 100644 --- a/lib/net/hippie/version.rb +++ b/lib/net/hippie/version.rb @@ -2,6 +2,6 @@ module Net module Hippie - VERSION = '0.1.7' + VERSION = '0.1.8' end end diff --git a/test/net/client_test.rb b/test/net/client_test.rb index 499f54c..c71943c 100644 --- a/test/net/client_test.rb +++ b/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') |
