httpi 2.2.7 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 498e0d42bbd55c69f3af23ceed4a8cccd5ef67a0
4
- data.tar.gz: ecc70c0b81c7589367cb251cd2212d1ae0860491
3
+ metadata.gz: 06ac8ba040207b5a0590492395b374fdcab38691
4
+ data.tar.gz: 2c4f27ee87ca5200523f3191081e243704504915
5
5
  SHA512:
6
- metadata.gz: c0aee94848b721977728c3c88aac525fd3765765e07811bf9d5cd789124570b13013a45ca56837579686505812b5020b28e0fcc2cb49312aefe1c590ed58aeb9
7
- data.tar.gz: 96bd3a4d7bf1b6a9bc2b529f780241e4a70db8fdbb32be36ad92ff9cd9369cecc9b09dc03055e879803ab7c0e3fe5b0cdd97d99a3dd0c13d7ced78dc38608cf7
6
+ metadata.gz: b81b972077db62ec3f8896a80d9a95c410dbddffcfbf681cdb0f7d322122fefb8c3b04ebfd92a403e8812a9f1c59fe333a15a4d4ed514a3fb3b48caf1ace6539
7
+ data.tar.gz: 3afa2f7660560043a23d03de67bacba6909951eb62dd23c1ad071dd893278260883b3c91d066758928d66a8297f368cb1c56a0cf9b77dd25819fe617c0c65271
@@ -1,3 +1,12 @@
1
+ ### 2.3.0
2
+
3
+ * Improvement: [#136](https://github.com/savonrb/httpi/pull/136) Allow setting of ssl versions depending on what versions OpenSSL provides at runtime.
4
+
5
+ ### 2.2.8 (edge)
6
+
7
+ * Improvement: [#133](https://github.com/savonrb/httpi/pull/133) Add 'query' to available attribute writers so it can be set with 'new'
8
+ * Fix: [#132](https://github.com/savonrb/httpi/pull/132) Fix a few warnings, among which a circular require
9
+
1
10
  ### 2.2.7
2
11
 
3
12
  * Fix: [#131](https://github.com/savonrb/httpi/pull/131) Excon adapter should respect :ssl_version
@@ -109,7 +109,7 @@ module HTTPI
109
109
  builder_name = builder.to_s.capitalize
110
110
  begin
111
111
  builder = HTTPI::QueryBuilder.const_get(builder_name)
112
- rescue NameError => ex
112
+ rescue NameError
113
113
  raise ArgumentError, "Invalid builder. Available builders are: [:flat, :nested]"
114
114
  end
115
115
  end
@@ -1,4 +1,3 @@
1
- require "httpi"
2
1
  require "httpi/adapter"
3
2
 
4
3
  module HTTPI
@@ -111,14 +111,17 @@ module HTTPI
111
111
  end
112
112
 
113
113
  @client.ssl_version = case ssl.ssl_version
114
- when :TLSv1 then 1
115
- when :SSLv2 then 2
116
- when :SSLv3 then 3
114
+ when :TLSv1_2 then 1
115
+ when :TLSv1_1 then 1
116
+ when :TLSv1 then 1
117
+ when :SSLv2 then 2
118
+ when :SSLv23 then 2
119
+ when :SSLv3 then 3
117
120
  end
118
121
  end
119
122
 
120
123
  def respond_with(client)
121
- status, headers = parse_header_string(client.header_str)
124
+ headers = parse_header_string(client.header_str).last
122
125
  Response.new client.response_code, headers, client.body_str
123
126
  end
124
127
 
@@ -170,7 +170,7 @@ module HTTPI
170
170
  end
171
171
 
172
172
  request_client = request_class.new @request.url.request_uri, @request.headers
173
- request_client.basic_auth *@request.auth.credentials if @request.auth.basic?
173
+ request_client.basic_auth(*@request.auth.credentials) if @request.auth.basic?
174
174
 
175
175
  if @request.auth.digest?
176
176
  raise NotSupportedError, "Net::HTTP does not support HTTP digest authentication"
@@ -10,7 +10,7 @@ module HTTPI
10
10
 
11
11
  VERIFY_MODES = [:none, :peer, :fail_if_no_peer_cert, :client_once]
12
12
  CERT_TYPES = [:pem, :der]
13
- SSL_VERSIONS = [:TLSv1, :SSLv2, :SSLv3]
13
+ SSL_VERSIONS = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }.sort.reverse
14
14
 
15
15
  # Returns whether SSL configuration is present.
16
16
  def present?
@@ -11,7 +11,7 @@ module HTTPI
11
11
  class Request
12
12
 
13
13
  # Available attribute writers.
14
- ATTRIBUTES = [:url, :proxy, :headers, :body, :open_timeout, :read_timeout, :follow_redirect]
14
+ ATTRIBUTES = [:url, :proxy, :headers, :body, :open_timeout, :read_timeout, :follow_redirect, :query]
15
15
 
16
16
  # Accepts a Hash of +args+ to mass assign attributes and authentication credentials.
17
17
  def initialize(args = {})
@@ -82,9 +82,9 @@ module HTTPI
82
82
  # or an Array of `HTTPI::Cookie` objects.
83
83
  def set_cookies(object_or_array)
84
84
  if object_or_array.respond_to?(:cookies)
85
- cookie_store.add *object_or_array.cookies
85
+ cookie_store.add(*object_or_array.cookies)
86
86
  else
87
- cookie_store.add *object_or_array
87
+ cookie_store.add(*object_or_array)
88
88
  end
89
89
 
90
90
  cookies = cookie_store.fetch
@@ -24,7 +24,8 @@ module HTTPI
24
24
  self.raw_body = body
25
25
  end
26
26
 
27
- attr_accessor :code, :headers, :raw_body, :attachments
27
+ attr_accessor :code, :headers, :raw_body
28
+ attr_writer :attachments
28
29
 
29
30
  # Returns whether the HTTP response is considered successful.
30
31
  def error?
@@ -1,3 +1,3 @@
1
1
  module HTTPI
2
- VERSION = '2.2.7'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -238,8 +238,10 @@ unless RUBY_PLATFORM =~ /java/
238
238
  adapter.request(:get)
239
239
  end
240
240
 
241
- it 'to 2 when ssl_version is specified as SSLv2' do
242
- request.auth.ssl.ssl_version = :SSLv2
241
+ it 'to 2 when ssl_version is specified as SSLv2/SSLv23' do
242
+ version = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }
243
+ version = version.select { |method| method.to_s.match /SSLv2|SSLv23/ }.first
244
+ request.auth.ssl.ssl_version = version
243
245
  curb.expects(:ssl_version=).with(2)
244
246
 
245
247
  adapter.request(:get)
@@ -2,6 +2,9 @@ require "spec_helper"
2
2
  require "httpi/auth/ssl"
3
3
 
4
4
  describe HTTPI::Auth::SSL do
5
+ before(:all) do
6
+ @ssl_versions = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }.sort.reverse
7
+ end
5
8
 
6
9
  describe "VERIFY_MODES" do
7
10
  it "contains the supported SSL verify modes" do
@@ -136,32 +139,22 @@ describe HTTPI::Auth::SSL do
136
139
 
137
140
  describe "SSL_VERSIONS" do
138
141
  it "contains the supported SSL versions" do
139
- expect(HTTPI::Auth::SSL::SSL_VERSIONS).to eq([:TLSv1, :SSLv2, :SSLv3])
142
+ expect(HTTPI::Auth::SSL::SSL_VERSIONS).to eq(@ssl_versions)
140
143
  end
141
144
  end
142
145
 
143
146
  describe "#ssl_version" do
144
147
  subject { HTTPI::Auth::SSL.new }
145
148
 
146
- it 'returns the SSL version for :TLSv1' do
147
- subject.ssl_version = :TLSv1
148
- expect(subject.ssl_version).to eq(:TLSv1)
149
- end
150
-
151
- it 'returns the SSL version for :SSLv2' do
152
- subject.ssl_version = :SSLv2
153
- expect(subject.ssl_version).to eq(:SSLv2)
154
- end
155
-
156
- it 'returns the SSL version for :SSLv3' do
157
- subject.ssl_version = :SSLv3
158
- expect(subject.ssl_version).to eq(:SSLv3)
149
+ it "returns the SSL version" do
150
+ subject.ssl_version = @ssl_versions.first
151
+ expect(subject.ssl_version).to eq(@ssl_versions.first)
159
152
  end
160
153
 
161
154
  it 'raises ArgumentError if the version is unsupported' do
162
155
  expect { ssl.ssl_version = :ssl_fail }.
163
156
  to raise_error(ArgumentError, "Invalid SSL version :ssl_fail\n" +
164
- "Please specify one of [:TLSv1, :SSLv2, :SSLv3]")
157
+ "Please specify one of #{@ssl_versions}")
165
158
  end
166
159
  end
167
160
 
@@ -11,9 +11,10 @@ describe HTTPI::Request do
11
11
  end
12
12
 
13
13
  it "accepts a Hash of accessors to set" do
14
- request = HTTPI::Request.new :url => "http://example.com", :open_timeout => 30
15
- expect(request.url).to eq(URI("http://example.com"))
14
+ request = HTTPI::Request.new :url => "http://example.com", :open_timeout => 30, :query => { key: "value" }
15
+ expect(request.url).to eq(URI("http://example.com?key=value"))
16
16
  expect(request.open_timeout).to eq(30)
17
+ expect(request.query).to eq("key=value")
17
18
  end
18
19
  end
19
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-24 00:00:00.000000000 Z
12
+ date: 2014-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack