httpi 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -3
- data/httpi.gemspec +1 -0
- data/lib/httpi.rb +3 -2
- data/lib/httpi/adapter/excon.rb +2 -1
- data/lib/httpi/adapter/net_http.rb +12 -10
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/httpi_spec.rb +28 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fdb3bb23a9cba076a235fac76aa7aa0aa04a803
|
4
|
+
data.tar.gz: 7740630503dc0ffedc3f909f1418d45f0a443156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a720954983eecb0fd4497f2c0e87269ceb5373c0856e19d4de9b7a102c7adba108e8fb44b020a80dc038b820355efffff9dfcdf0dad94f24668953c4d9b38d
|
7
|
+
data.tar.gz: 5f8119a473f8daf6c7dfd597a172002ead1f5b1fceea7456c083e14a9daee93da63d23a7018030103389a3397ae9e6df986780e032a7612f5d39a482b3619f5c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
### 2.
|
1
|
+
### 2.4.0
|
2
2
|
|
3
|
-
*
|
3
|
+
* Formally drop support for ruby 1.8.7
|
4
4
|
|
5
|
-
### 2.
|
5
|
+
### 2.3.0
|
6
6
|
|
7
|
+
* Improvement: [#136](https://github.com/savonrb/httpi/pull/136) Allow setting of ssl versions depending on what versions OpenSSL provides at runtime.
|
7
8
|
* Improvement: [#133](https://github.com/savonrb/httpi/pull/133) Add 'query' to available attribute writers so it can be set with 'new'
|
8
9
|
* Fix: [#132](https://github.com/savonrb/httpi/pull/132) Fix a few warnings, among which a circular require
|
9
10
|
|
data/httpi.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/savonrb/#{s.name}"
|
12
12
|
s.summary = "Common interface for Ruby's HTTP libraries"
|
13
13
|
s.description = s.summary
|
14
|
+
s.required_ruby_version = '>= 1.9.2'
|
14
15
|
|
15
16
|
s.rubyforge_project = s.name
|
16
17
|
s.license = 'MIT'
|
data/lib/httpi.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "uri"
|
1
2
|
require "httpi/version"
|
2
3
|
require "httpi/logger"
|
3
4
|
require "httpi/request"
|
@@ -159,8 +160,8 @@ module HTTPI
|
|
159
160
|
response = adapter_class.request(method)
|
160
161
|
|
161
162
|
if response && HTTPI::Response::RedirectResponseCodes.member?(response.code) && request.follow_redirect?
|
162
|
-
|
163
|
-
request.url
|
163
|
+
request.url = URI.join(request.url, response.headers['location'])
|
164
|
+
log("Following redirect: '#{request.url}'.")
|
164
165
|
return request(method, request, adapter)
|
165
166
|
end
|
166
167
|
|
data/lib/httpi/adapter/excon.rb
CHANGED
@@ -66,9 +66,10 @@ module HTTPI
|
|
66
66
|
opts[:ssl_ca_file] = ssl.ca_cert_file if ssl.ca_cert_file
|
67
67
|
opts[:client_cert] = ssl.cert if ssl.cert
|
68
68
|
opts[:client_key] = ssl.cert_key if ssl.cert_key
|
69
|
-
opts[:ssl_version] = ssl.ssl_version if ssl.ssl_version
|
70
69
|
end
|
71
70
|
|
71
|
+
opts[:ssl_version] = ssl.ssl_version if ssl.ssl_version
|
72
|
+
|
72
73
|
opts
|
73
74
|
end
|
74
75
|
|
@@ -5,15 +5,6 @@ require "httpi/response"
|
|
5
5
|
require 'kconv'
|
6
6
|
require 'socket'
|
7
7
|
|
8
|
-
begin
|
9
|
-
require 'net/ntlm'
|
10
|
-
require 'net/ntlm/version' unless Net::NTLM.const_defined?(:VERSION)
|
11
|
-
unless Net::NTLM::VERSION::STRING >= '0.3.2'
|
12
|
-
raise ArgumentError, 'Invalid version of rubyntlm. Please use v0.3.2+.'
|
13
|
-
end
|
14
|
-
rescue LoadError
|
15
|
-
end
|
16
|
-
|
17
8
|
module HTTPI
|
18
9
|
module Adapter
|
19
10
|
|
@@ -24,8 +15,9 @@ module HTTPI
|
|
24
15
|
class NetHTTP < Base
|
25
16
|
|
26
17
|
register :net_http, :deps => %w(net/https)
|
27
|
-
|
28
18
|
def initialize(request)
|
19
|
+
check_net_ntlm_version!
|
20
|
+
|
29
21
|
@request = request
|
30
22
|
@client = create_client
|
31
23
|
end
|
@@ -58,6 +50,16 @@ module HTTPI
|
|
58
50
|
end
|
59
51
|
|
60
52
|
private
|
53
|
+
def check_net_ntlm_version!
|
54
|
+
begin
|
55
|
+
require 'net/ntlm'
|
56
|
+
require 'net/ntlm/version' unless Net::NTLM.const_defined?(:VERSION)
|
57
|
+
unless Net::NTLM::VERSION::STRING >= '0.3.2'
|
58
|
+
raise ArgumentError, 'Invalid version of rubyntlm. Please use v0.3.2+.'
|
59
|
+
end
|
60
|
+
rescue LoadError
|
61
|
+
end
|
62
|
+
end
|
61
63
|
|
62
64
|
def perform(http, http_request, &block)
|
63
65
|
http.request http_request, &block
|
data/lib/httpi/version.rb
CHANGED
data/spec/httpi/httpi_spec.rb
CHANGED
@@ -222,7 +222,7 @@ describe HTTPI do
|
|
222
222
|
end
|
223
223
|
|
224
224
|
describe ".request" do
|
225
|
-
let(:request) { HTTPI::Request.new('http://example.com') }
|
225
|
+
let(:request) { HTTPI::Request.new('http://example.com/foo/') }
|
226
226
|
|
227
227
|
it "allows custom HTTP methods" do
|
228
228
|
httpclient.any_instance.expects(:request).with(:custom)
|
@@ -238,7 +238,33 @@ describe HTTPI do
|
|
238
238
|
response = HTTPI::Response.new(200, {}, 'success')
|
239
239
|
|
240
240
|
httpclient.any_instance.expects(:request).twice.with(:custom).returns(redirect, response)
|
241
|
-
request.expects(:url=).with(redirect_location)
|
241
|
+
request.expects(:url=).with(URI.parse(redirect_location))
|
242
|
+
|
243
|
+
client.request(:custom, request, :httpclient)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'follows redirects with absolute path' do
|
247
|
+
request.follow_redirect = true
|
248
|
+
redirect_location = '/bar/foo'
|
249
|
+
|
250
|
+
redirect = HTTPI::Response.new(302, {'location' => redirect_location}, 'Moved')
|
251
|
+
response = HTTPI::Response.new(200, {}, 'success')
|
252
|
+
|
253
|
+
httpclient.any_instance.expects(:request).twice.with(:custom).returns(redirect, response)
|
254
|
+
request.expects(:url=).with(URI.parse('http://example.com/bar/foo'))
|
255
|
+
|
256
|
+
client.request(:custom, request, :httpclient)
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'follows redirects with relative path' do
|
260
|
+
request.follow_redirect = true
|
261
|
+
redirect_location = 'bar/foo'
|
262
|
+
|
263
|
+
redirect = HTTPI::Response.new(302, {'location' => redirect_location}, 'Moved')
|
264
|
+
response = HTTPI::Response.new(200, {}, 'success')
|
265
|
+
|
266
|
+
httpclient.any_instance.expects(:request).twice.with(:custom).returns(redirect, response)
|
267
|
+
request.expects(:url=).with(URI.parse('http://example.com/foo/bar/foo'))
|
242
268
|
|
243
269
|
client.request(:custom, request, :httpclient)
|
244
270
|
end
|
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.
|
4
|
+
version: 2.4.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:
|
12
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
180
|
requirements:
|
181
181
|
- - ">="
|
182
182
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
183
|
+
version: 1.9.2
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
186
|
- - ">="
|