httpi 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +32 -0
- data/lib/httpi.rb +12 -12
- data/lib/httpi/adapter.rb +40 -41
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/adapter_spec.rb +16 -44
- data/spec/httpi/httpi_spec.rb +35 -55
- metadata +5 -4
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## 0.9.0 (2011-03-08)
|
2
|
+
|
3
|
+
* Feature: improved the adapter loading process ([d4a091](https://github.com/rubiii/savon/commit/d4a091)) [rubiii].
|
4
|
+
|
5
|
+
Instead of using HTTPClient as the default and falling back to NetHTTP, the loading process now does the following:
|
6
|
+
|
7
|
+
1. Check if either HTTPClient, Curb or NetHTTP are already defined.
|
8
|
+
If any one of those is defined, use it.
|
9
|
+
|
10
|
+
2. Try to require HTTPClient, Curb and NetHTTP at last.
|
11
|
+
If any one of those can be required, use it.
|
12
|
+
|
13
|
+
Of course you can still manually specify the adapter to use.
|
14
|
+
|
15
|
+
* Fix: [issue 22](https://github.com/rubiii/httpi/issues/22) argument error on logging adapter warning [rubiii].
|
16
|
+
|
17
|
+
* Fix: [issue 23](https://github.com/rubiii/httpi/issues/23) the HTTPI.log method now works as expected [rubiii].
|
18
|
+
|
19
|
+
## 0.8.0 (2011-03-07)
|
20
|
+
|
21
|
+
* Feature: added support for NTLM authentication ([96ceb1](https://github.com/rubiii/savon/commit/96ceb1)) [MattHall].
|
22
|
+
|
23
|
+
You should now be able to use NTLM authentication by specifying your credentials via `HTTPI::Auth::Config#ntlm`:
|
24
|
+
|
25
|
+
request = HTTPI::Request.new
|
26
|
+
request.auth.ntlm "username", "password"
|
27
|
+
|
28
|
+
* Improvement: changed the default log level to :warn ([d01591](https://github.com/rubiii/savon/commit/d01591))
|
29
|
+
and log at appropriate levels ([21ee1b](https://github.com/rubiii/savon/commit/21ee1b)) [ichverstehe].
|
30
|
+
|
31
|
+
* Fix: [issue 18](https://github.com/rubiii/httpi/issues/18) don't mask exceptions in decoded_gzip_body
|
32
|
+
([f3811b](https://github.com/rubiii/savon/commit/f3811b)) [fj].
|
data/lib/httpi.rb
CHANGED
@@ -24,7 +24,7 @@ require "httpi/adapter"
|
|
24
24
|
# request = HTTPI::Request.new
|
25
25
|
# request.url = "http://example.com"
|
26
26
|
# request.body = "<some>xml</some>"
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# HTTPI.post request, :httpclient
|
29
29
|
#
|
30
30
|
# === Shortcuts
|
@@ -45,7 +45,7 @@ require "httpi/adapter"
|
|
45
45
|
# request = HTTPI::Request.new
|
46
46
|
# request.url = "http://example.com"
|
47
47
|
# request.body = "<some>xml</some>"
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# HTTPI.put request, :httpclient
|
50
50
|
#
|
51
51
|
# === Shortcuts
|
@@ -80,7 +80,7 @@ module HTTPI
|
|
80
80
|
# Executes an HTTP GET request.
|
81
81
|
def get(request, adapter = nil)
|
82
82
|
request = Request.new :url => request if request.kind_of? String
|
83
|
-
|
83
|
+
|
84
84
|
with_adapter :get, request, adapter do |adapter|
|
85
85
|
yield adapter.client if block_given?
|
86
86
|
adapter.get request
|
@@ -90,7 +90,7 @@ module HTTPI
|
|
90
90
|
# Executes an HTTP POST request.
|
91
91
|
def post(*args)
|
92
92
|
request, adapter = request_and_adapter_from(args)
|
93
|
-
|
93
|
+
|
94
94
|
with_adapter :post, request, adapter do |adapter|
|
95
95
|
yield adapter.client if block_given?
|
96
96
|
adapter.post request
|
@@ -100,7 +100,7 @@ module HTTPI
|
|
100
100
|
# Executes an HTTP HEAD request.
|
101
101
|
def head(request, adapter = nil)
|
102
102
|
request = Request.new :url => request if request.kind_of? String
|
103
|
-
|
103
|
+
|
104
104
|
with_adapter :head, request, adapter do |adapter|
|
105
105
|
yield adapter.client if block_given?
|
106
106
|
adapter.head request
|
@@ -110,7 +110,7 @@ module HTTPI
|
|
110
110
|
# Executes an HTTP PUT request.
|
111
111
|
def put(*args)
|
112
112
|
request, adapter = request_and_adapter_from(args)
|
113
|
-
|
113
|
+
|
114
114
|
with_adapter :put, request, adapter do |adapter|
|
115
115
|
yield adapter.client if block_given?
|
116
116
|
adapter.put request
|
@@ -120,7 +120,7 @@ module HTTPI
|
|
120
120
|
# Executes an HTTP DELETE request.
|
121
121
|
def delete(request, adapter = nil)
|
122
122
|
request = Request.new :url => request if request.kind_of? String
|
123
|
-
|
123
|
+
|
124
124
|
with_adapter :delete, request, adapter do |adapter|
|
125
125
|
yield adapter.client if block_given?
|
126
126
|
adapter.delete request
|
@@ -159,7 +159,8 @@ module HTTPI
|
|
159
159
|
|
160
160
|
# Logs given +messages+.
|
161
161
|
def log(*messages)
|
162
|
-
|
162
|
+
level = Symbol === messages.first ? messages.shift : log_level
|
163
|
+
logger.send level, messages.join(" ") if log?
|
163
164
|
end
|
164
165
|
|
165
166
|
# Reset the default config.
|
@@ -182,10 +183,9 @@ module HTTPI
|
|
182
183
|
# Expects a request +method+, a +request+ and an +adapter+ (defaults to
|
183
184
|
# <tt>Adapter.use</tt>) and yields an instance of the adapter to a given block.
|
184
185
|
def with_adapter(method, request, adapter)
|
185
|
-
adapter
|
186
|
-
|
187
|
-
|
188
|
-
HTTPI.logger.debug "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter"
|
186
|
+
adapter, adapter_class = Adapter.load adapter
|
187
|
+
|
188
|
+
log :debug, "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter"
|
189
189
|
yield adapter_class.new(request)
|
190
190
|
end
|
191
191
|
|
data/lib/httpi/adapter.rb
CHANGED
@@ -13,56 +13,55 @@ module HTTPI
|
|
13
13
|
# * net/http
|
14
14
|
module Adapter
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
ADAPTERS = {
|
17
|
+
:httpclient => HTTPClient,
|
18
|
+
:curb => Curb,
|
19
|
+
:net_http => NetHTTP
|
20
|
+
}
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
DEPENDENCIES = [
|
23
|
+
[:httpclient, ["httpclient"]],
|
24
|
+
[:curb, ["curb"]],
|
25
|
+
[:net_http, ["net/https", "net/ntlm_http"]]
|
26
|
+
]
|
21
27
|
|
22
|
-
|
23
|
-
def self.use
|
24
|
-
@use ||= DEFAULT
|
25
|
-
end
|
28
|
+
class << self
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@use = adapter
|
31
|
-
end
|
30
|
+
def use=(adapter)
|
31
|
+
@adapter = adapter.nil? ? nil : validate_adapter!(adapter)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:httpclient => { :class => HTTPClient, :require => ["httpclient"] },
|
37
|
-
:curb => { :class => Curb, :require => ["curb"] },
|
38
|
-
:net_http => { :class => NetHTTP, :require => ["net/https", "net/ntlm_http"] }
|
39
|
-
}
|
40
|
-
end
|
34
|
+
def use
|
35
|
+
@adapter ||= default_adapter
|
36
|
+
end
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
38
|
+
def load(adapter = nil)
|
39
|
+
adapter = adapter ? validate_adapter!(adapter) : use
|
40
|
+
[adapter, ADAPTERS[adapter]]
|
41
|
+
end
|
47
42
|
|
48
|
-
|
43
|
+
private
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
def validate_adapter!(adapter)
|
46
|
+
raise ArgumentError, "Invalid HTTPI adapter: #{adapter}" unless ADAPTERS[adapter]
|
47
|
+
adapter
|
48
|
+
end
|
54
49
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
rescue LoadError
|
60
|
-
HTTPI.logger.warn "HTTPI tried to use the #{adapter} adapter, but was unable to find the library in the LOAD_PATH.",
|
61
|
-
"Falling back to using the #{FALLBACK} adapter now."
|
50
|
+
def default_adapter
|
51
|
+
return :httpclient if defined?(::HTTPClient)
|
52
|
+
return :curb if defined?(::Curl::Easy)
|
53
|
+
return :net_http if defined?(::NetHTTP)
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
DEPENDENCIES.each do |(adapter, dependencies)|
|
56
|
+
begin
|
57
|
+
dependencies.each { |dependency| require dependency }
|
58
|
+
return adapter
|
59
|
+
rescue LoadError
|
60
|
+
next
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
66
64
|
|
65
|
+
end
|
67
66
|
end
|
68
67
|
end
|
data/lib/httpi/version.rb
CHANGED
data/spec/httpi/adapter_spec.rb
CHANGED
@@ -1,68 +1,40 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "httpi/adapter"
|
3
3
|
|
4
|
+
|
4
5
|
describe HTTPI::Adapter do
|
5
6
|
let(:adapter) { HTTPI::Adapter }
|
6
7
|
|
7
8
|
describe ".use" do
|
8
|
-
it "should
|
9
|
-
adapter.use.
|
10
|
-
|
11
|
-
|
12
|
-
it "should accept an adapter to use" do
|
9
|
+
it "should set the adapter to use" do
|
10
|
+
adapter.use.should_not == :curb
|
11
|
+
|
13
12
|
adapter.use = :curb
|
14
13
|
adapter.use.should == :curb
|
15
|
-
|
16
|
-
# reset to default
|
17
|
-
adapter.use = HTTPI::Adapter::DEFAULT
|
18
|
-
end
|
19
14
|
|
20
|
-
|
21
|
-
lambda { adapter.use = :unknown }.should raise_error(ArgumentError)
|
15
|
+
adapter.use = nil # reset
|
22
16
|
end
|
23
|
-
end
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
adapter.adapters.should == {
|
28
|
-
:httpclient => { :class => HTTPI::Adapter::HTTPClient, :require => "httpclient" },
|
29
|
-
:curb => { :class => HTTPI::Adapter::Curb, :require => "curb" },
|
30
|
-
:net_http => { :class => HTTPI::Adapter::NetHTTP, :require => "net/https" }
|
31
|
-
}
|
18
|
+
it "should default to use the HTTPClient adapter" do
|
19
|
+
adapter.use.should == :httpclient
|
32
20
|
end
|
33
21
|
|
34
|
-
it "should
|
35
|
-
adapter.
|
22
|
+
it "should raise an ArgumentError in case of an invalid adapter" do
|
23
|
+
lambda { adapter.use = :unknown }.should raise_error(ArgumentError)
|
36
24
|
end
|
37
25
|
end
|
38
26
|
|
39
|
-
describe ".
|
40
|
-
it "should return the adapter name and class for a given
|
41
|
-
adapter.
|
27
|
+
describe ".load" do
|
28
|
+
it "should return the adapter name and it's class for a given adapter" do
|
29
|
+
adapter.load(:curb).should == [:curb, HTTPI::Adapter::Curb]
|
42
30
|
end
|
43
31
|
|
44
|
-
it "should
|
45
|
-
|
32
|
+
it "should return the HTTPClient adapter name and it's class by default" do
|
33
|
+
adapter.load.should == [:httpclient, HTTPI::Adapter::HTTPClient]
|
46
34
|
end
|
47
35
|
|
48
|
-
|
49
|
-
|
50
|
-
adapter.expects(:require).with("httpclient").raises(LoadError)
|
51
|
-
adapter.expects(:require).with(HTTPI::Adapter.adapters[HTTPI::Adapter::FALLBACK][:require])
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should fall back to use the HTTPI::Adapter::FALLBACK adapter" do
|
55
|
-
adapter.find :httpclient
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should log that the adapter to use could not be required" do
|
59
|
-
HTTPI.expects(:log).with(
|
60
|
-
"HTTPI tried to use the httpclient adapter, but was unable to find the library in the LOAD_PATH.",
|
61
|
-
"Falling back to using the #{HTTPI::Adapter::FALLBACK} adapter now."
|
62
|
-
)
|
63
|
-
|
64
|
-
adapter.find :httpclient
|
65
|
-
end
|
36
|
+
it "should raise an ArgumentError in case of an invalid adapter" do
|
37
|
+
lambda { adapter.use = :unknown }.should raise_error(ArgumentError)
|
66
38
|
end
|
67
39
|
end
|
68
40
|
|
data/spec/httpi/httpi_spec.rb
CHANGED
@@ -3,14 +3,14 @@ require "httpi"
|
|
3
3
|
|
4
4
|
describe HTTPI do
|
5
5
|
let(:client) { HTTPI }
|
6
|
-
let(:
|
7
|
-
let(:curb) { HTTPI::Adapter.
|
6
|
+
let(:httpclient) { HTTPI::Adapter.load(:httpclient)[1] }
|
7
|
+
let(:curb) { HTTPI::Adapter.load(:curb)[1] }
|
8
8
|
|
9
9
|
describe ".get(request)" do
|
10
10
|
it "should execute an HTTP GET request using the default adapter" do
|
11
11
|
request = HTTPI::Request.new
|
12
|
-
|
13
|
-
|
12
|
+
httpclient.any_instance.expects(:get).with(request)
|
13
|
+
|
14
14
|
client.get request
|
15
15
|
end
|
16
16
|
end
|
@@ -19,7 +19,7 @@ describe HTTPI do
|
|
19
19
|
it "should execute an HTTP GET request using the given adapter" do
|
20
20
|
request = HTTPI::Request.new
|
21
21
|
curb.any_instance.expects(:get).with(request)
|
22
|
-
|
22
|
+
|
23
23
|
client.get request, :curb
|
24
24
|
end
|
25
25
|
end
|
@@ -27,8 +27,8 @@ describe HTTPI do
|
|
27
27
|
describe ".get(url)" do
|
28
28
|
it "should execute an HTTP GET request using the default adapter" do
|
29
29
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
30
|
-
|
31
|
-
|
30
|
+
httpclient.any_instance.expects(:get).with(instance_of(HTTPI::Request))
|
31
|
+
|
32
32
|
client.get "http://example.com"
|
33
33
|
end
|
34
34
|
end
|
@@ -37,7 +37,7 @@ describe HTTPI do
|
|
37
37
|
it "should execute an HTTP GET request using the given adapter" do
|
38
38
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
39
39
|
curb.any_instance.expects(:get).with(instance_of(HTTPI::Request))
|
40
|
-
|
40
|
+
|
41
41
|
client.get "http://example.com", :curb
|
42
42
|
end
|
43
43
|
end
|
@@ -45,8 +45,8 @@ describe HTTPI do
|
|
45
45
|
describe ".post(request)" do
|
46
46
|
it "should execute an HTTP POST request using the default adapter" do
|
47
47
|
request = HTTPI::Request.new
|
48
|
-
|
49
|
-
|
48
|
+
httpclient.any_instance.expects(:post).with(request)
|
49
|
+
|
50
50
|
client.post request
|
51
51
|
end
|
52
52
|
end
|
@@ -55,7 +55,7 @@ describe HTTPI do
|
|
55
55
|
it "should execute an HTTP POST request using the given adapter" do
|
56
56
|
request = HTTPI::Request.new
|
57
57
|
curb.any_instance.expects(:post).with(request)
|
58
|
-
|
58
|
+
|
59
59
|
client.post request, :curb
|
60
60
|
end
|
61
61
|
end
|
@@ -64,8 +64,8 @@ describe HTTPI do
|
|
64
64
|
it "should execute an HTTP POST request using the default adapter" do
|
65
65
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
66
66
|
HTTPI::Request.any_instance.expects(:body=).with("<some>xml</some>")
|
67
|
-
|
68
|
-
|
67
|
+
httpclient.any_instance.expects(:post).with(instance_of(HTTPI::Request))
|
68
|
+
|
69
69
|
client.post "http://example.com", "<some>xml</some>"
|
70
70
|
end
|
71
71
|
end
|
@@ -75,7 +75,7 @@ describe HTTPI do
|
|
75
75
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
76
76
|
HTTPI::Request.any_instance.expects(:body=).with("<some>xml</some>")
|
77
77
|
curb.any_instance.expects(:post).with(instance_of(HTTPI::Request))
|
78
|
-
|
78
|
+
|
79
79
|
client.post "http://example.com", "<some>xml</some>", :curb
|
80
80
|
end
|
81
81
|
end
|
@@ -83,8 +83,8 @@ describe HTTPI do
|
|
83
83
|
describe ".head(request)" do
|
84
84
|
it "should execute an HTTP HEAD request using the default adapter" do
|
85
85
|
request = HTTPI::Request.new
|
86
|
-
|
87
|
-
|
86
|
+
httpclient.any_instance.expects(:head).with(request)
|
87
|
+
|
88
88
|
client.head request
|
89
89
|
end
|
90
90
|
end
|
@@ -93,7 +93,7 @@ describe HTTPI do
|
|
93
93
|
it "should execute an HTTP HEAD request using the given adapter" do
|
94
94
|
request = HTTPI::Request.new
|
95
95
|
curb.any_instance.expects(:head).with(request)
|
96
|
-
|
96
|
+
|
97
97
|
client.head request, :curb
|
98
98
|
end
|
99
99
|
end
|
@@ -101,8 +101,8 @@ describe HTTPI do
|
|
101
101
|
describe ".head(url)" do
|
102
102
|
it "should execute an HTTP HEAD request using the default adapter" do
|
103
103
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
104
|
-
|
105
|
-
|
104
|
+
httpclient.any_instance.expects(:head).with(instance_of(HTTPI::Request))
|
105
|
+
|
106
106
|
client.head "http://example.com"
|
107
107
|
end
|
108
108
|
end
|
@@ -111,7 +111,7 @@ describe HTTPI do
|
|
111
111
|
it "should execute an HTTP HEAD request using the given adapter" do
|
112
112
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
113
113
|
curb.any_instance.expects(:head).with(instance_of(HTTPI::Request))
|
114
|
-
|
114
|
+
|
115
115
|
client.head "http://example.com", :curb
|
116
116
|
end
|
117
117
|
end
|
@@ -119,8 +119,8 @@ describe HTTPI do
|
|
119
119
|
describe ".put(request)" do
|
120
120
|
it "should execute an HTTP PUT request using the default adapter" do
|
121
121
|
request = HTTPI::Request.new
|
122
|
-
|
123
|
-
|
122
|
+
httpclient.any_instance.expects(:put).with(request)
|
123
|
+
|
124
124
|
client.put request
|
125
125
|
end
|
126
126
|
end
|
@@ -129,7 +129,7 @@ describe HTTPI do
|
|
129
129
|
it "should execute an HTTP PUT request using the given adapter" do
|
130
130
|
request = HTTPI::Request.new
|
131
131
|
curb.any_instance.expects(:put).with(request)
|
132
|
-
|
132
|
+
|
133
133
|
client.put request, :curb
|
134
134
|
end
|
135
135
|
end
|
@@ -138,8 +138,8 @@ describe HTTPI do
|
|
138
138
|
it "should execute an HTTP PUT request using the default adapter" do
|
139
139
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
140
140
|
HTTPI::Request.any_instance.expects(:body=).with("<some>xml</some>")
|
141
|
-
|
142
|
-
|
141
|
+
httpclient.any_instance.expects(:put).with(instance_of(HTTPI::Request))
|
142
|
+
|
143
143
|
client.put "http://example.com", "<some>xml</some>"
|
144
144
|
end
|
145
145
|
end
|
@@ -149,7 +149,7 @@ describe HTTPI do
|
|
149
149
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
150
150
|
HTTPI::Request.any_instance.expects(:body=).with("<some>xml</some>")
|
151
151
|
curb.any_instance.expects(:put).with(instance_of(HTTPI::Request))
|
152
|
-
|
152
|
+
|
153
153
|
client.put "http://example.com", "<some>xml</some>", :curb
|
154
154
|
end
|
155
155
|
end
|
@@ -157,8 +157,8 @@ describe HTTPI do
|
|
157
157
|
describe ".delete(request)" do
|
158
158
|
it "should execute an HTTP DELETE request using the default adapter" do
|
159
159
|
request = HTTPI::Request.new
|
160
|
-
|
161
|
-
|
160
|
+
httpclient.any_instance.expects(:delete).with(request)
|
161
|
+
|
162
162
|
client.delete request
|
163
163
|
end
|
164
164
|
end
|
@@ -167,7 +167,7 @@ describe HTTPI do
|
|
167
167
|
it "should execute an HTTP DELETE request using the given adapter" do
|
168
168
|
request = HTTPI::Request.new
|
169
169
|
curb.any_instance.expects(:delete).with(request)
|
170
|
-
|
170
|
+
|
171
171
|
client.delete request, :curb
|
172
172
|
end
|
173
173
|
end
|
@@ -175,8 +175,8 @@ describe HTTPI do
|
|
175
175
|
describe ".delete(url)" do
|
176
176
|
it "should execute an HTTP DELETE request using the default adapter" do
|
177
177
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
178
|
-
|
179
|
-
|
178
|
+
httpclient.any_instance.expects(:delete).with(instance_of(HTTPI::Request))
|
179
|
+
|
180
180
|
client.delete "http://example.com"
|
181
181
|
end
|
182
182
|
end
|
@@ -185,7 +185,7 @@ describe HTTPI do
|
|
185
185
|
it "should execute an HTTP DELETE request using the given adapter" do
|
186
186
|
HTTPI::Request.any_instance.expects(:url=).with("http://example.com")
|
187
187
|
curb.any_instance.expects(:delete).with(instance_of(HTTPI::Request))
|
188
|
-
|
188
|
+
|
189
189
|
client.delete "http://example.com", :curb
|
190
190
|
end
|
191
191
|
end
|
@@ -215,7 +215,7 @@ describe HTTPI do
|
|
215
215
|
lambda { client.request method, "invalid" }.should raise_error(ArgumentError)
|
216
216
|
end
|
217
217
|
|
218
|
-
HTTPI::Adapter.
|
218
|
+
HTTPI::Adapter::ADAPTERS.each do |adapter, adapter_class|
|
219
219
|
client_class = {
|
220
220
|
:httpclient => lambda { HTTPClient },
|
221
221
|
:curb => lambda { Curl::Easy },
|
@@ -223,10 +223,10 @@ describe HTTPI do
|
|
223
223
|
}
|
224
224
|
|
225
225
|
context "using #{adapter}" do
|
226
|
-
before {
|
226
|
+
before { adapter_class.any_instance.expects(method) }
|
227
227
|
|
228
228
|
it "should log that we're executing an HTTP request" do
|
229
|
-
HTTPI.expects(:log).with("HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter")
|
229
|
+
HTTPI.expects(:log).with(:debug, "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter")
|
230
230
|
client.request method, request, adapter
|
231
231
|
end
|
232
232
|
|
@@ -236,26 +236,6 @@ describe HTTPI do
|
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
239
|
-
|
240
|
-
HTTPI::Adapter.adapters.reject { |key, value| key == HTTPI::Adapter::FALLBACK }.each do |adapter, values|
|
241
|
-
context "when #{adapter} could not be loaded" do
|
242
|
-
before do
|
243
|
-
HTTPI::Adapter.expects(:require).with(values[:require]).raises(LoadError)
|
244
|
-
HTTPI::Adapter.expects(:require).with("net/https")
|
245
|
-
HTTPI::Adapter::NetHTTP.any_instance.expects(method)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should fall back to using the FALLBACK adapter" do
|
249
|
-
HTTPI.expects(:log).with(
|
250
|
-
"HTTPI tried to use the #{adapter} adapter, but was unable to find the library in the LOAD_PATH.",
|
251
|
-
"Falling back to using the #{HTTPI::Adapter::FALLBACK} adapter now."
|
252
|
-
)
|
253
|
-
HTTPI.expects(:log).with("HTTPI executes HTTP #{method.to_s.upcase} using the #{HTTPI::Adapter::FALLBACK} adapter")
|
254
|
-
|
255
|
-
client.request method, request, adapter
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
239
|
end
|
260
240
|
end
|
261
241
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-03-
|
19
|
+
date: 2011-03-08 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- .autotest
|
155
155
|
- .gitignore
|
156
156
|
- .rspec
|
157
|
+
- CHANGELOG.md
|
157
158
|
- Gemfile
|
158
159
|
- LICENSE
|
159
160
|
- README.md
|