httpi 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +3 -3
- data/lib/httpi/adapter/curb.rb +3 -2
- data/lib/httpi/adapter/em_http.rb +5 -4
- data/lib/httpi/adapter/excon.rb +2 -1
- data/lib/httpi/adapter/http.rb +6 -0
- data/lib/httpi/adapter/httpclient.rb +1 -0
- data/lib/httpi/adapter/net_http.rb +7 -0
- data/lib/httpi/adapter/net_http_persistent.rb +1 -0
- data/lib/httpi/auth/ssl.rb +1 -1
- data/lib/httpi/request.rb +2 -2
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/adapter/curb_spec.rb +14 -7
- data/spec/httpi/adapter/em_http_spec.rb +21 -13
- data/spec/httpi/adapter/excon_spec.rb +23 -119
- data/spec/httpi/adapter/http_spec.rb +23 -96
- data/spec/httpi/adapter/httpclient_spec.rb +14 -0
- data/spec/httpi/adapter/net_http_persistent_spec.rb +31 -81
- data/spec/httpi/adapter/net_http_spec.rb +37 -181
- data/spec/integration/curb_spec.rb +11 -0
- data/spec/integration/em_http_spec.rb +17 -0
- data/spec/integration/excon_spec.rb +47 -0
- data/spec/integration/http_spec.rb +28 -0
- data/spec/integration/httpclient_spec.rb +11 -0
- data/spec/integration/net_http_persistent_spec.rb +21 -2
- data/spec/integration/net_http_spec.rb +117 -1
- data/spec/integration/support/application.rb +3 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a39851ef3ab42a8c7ff8ddda62256da8f5f42b34fe0df16910686e4c25bf4565
|
4
|
+
data.tar.gz: 627e8c2ae552288e8066f3305d9cf245dcb3c51d7421ab5dee9e731cb85e6f68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f811738a0681dab582710c91b25c0210924bda41332413d50761ddb466121e7551a81f2bc9dcc3caba8bbe6bd5dbb9ec0dffa761e1e20aca4f28e9ffa02fa1f6
|
7
|
+
data.tar.gz: 7a5f15293b034a71187dd5fbae304b763eca335dd20f05e1007f56c3770995c618446d4867d8b6dc8fa5e2f7b722abd490d2e71ca9a955e2470498f3fba76945
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 2.4.4
|
2
|
+
|
3
|
+
* Improvement: [#197](https://github.com/savonrb/httpi/pull/197) Add support for new write timeout option to all adapters
|
4
|
+
* Fix: [#196](https://github.com/savonrb/httpi/pull/196) Fix httpi adapters support for read/open timeout
|
5
|
+
* Improvement: [Remove references to broken site](https://github.com/savonrb/httpi/commit/345e5e2b1a4376a7be769f67088a431895de09ad)
|
6
|
+
* Fix: [#190](https://github.com/savonrb/httpi/pull/190) Don't convert port to string on Excon adapter
|
7
|
+
|
1
8
|
### 2.4.3
|
2
9
|
|
3
10
|
* Fix: [#171](https://github.com/savonrb/httpi/pull/171) bug with rubyntlm v0.6.0
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A common interface for Ruby's HTTP libraries.
|
4
4
|
|
5
|
-
[Documentation](
|
5
|
+
[Documentation](https://www.rubydoc.info/gems/httpi) |
|
6
6
|
[Mailing list](https://groups.google.com/forum/#!forum/httpirb)
|
7
7
|
|
8
8
|
[](http://travis-ci.org/savonrb/httpi)
|
@@ -13,7 +13,7 @@ A common interface for Ruby's HTTP libraries.
|
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
16
|
-
HTTPI is available through [Rubygems](
|
16
|
+
HTTPI is available through [Rubygems](https://rubygems.org/gems/httpi) and can be installed via:
|
17
17
|
|
18
18
|
```
|
19
19
|
$ gem install httpi
|
@@ -52,4 +52,4 @@ HTTPI.request(:custom, request)
|
|
52
52
|
|
53
53
|
## Documentation
|
54
54
|
|
55
|
-
Continue reading at
|
55
|
+
Continue reading at https://www.rubydoc.info/gems/httpi
|
data/lib/httpi/adapter/curb.rb
CHANGED
@@ -72,8 +72,9 @@ module HTTPI
|
|
72
72
|
def basic_setup
|
73
73
|
@client.url = @request.url.to_s
|
74
74
|
@client.proxy_url = @request.proxy.to_s if @request.proxy
|
75
|
-
|
76
|
-
@client.
|
75
|
+
read_or_write_timeout = @request.read_timeout || @request.write_timeout
|
76
|
+
@client.timeout_ms = read_or_write_timeout * 1000 if read_or_write_timeout
|
77
|
+
@client.connect_timeout_ms = @request.open_timeout * 1000 if @request.open_timeout
|
77
78
|
@client.headers = @request.headers.to_hash
|
78
79
|
@client.verbose = false
|
79
80
|
# cURL workaround
|
@@ -69,10 +69,11 @@ module HTTPI
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def connection_options
|
72
|
-
options = {
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
options = {}
|
73
|
+
|
74
|
+
read_or_write_timeout = @request.read_timeout || @request.write_timeout
|
75
|
+
options[:inactivity_timeout] = read_or_write_timeout if read_or_write_timeout
|
76
|
+
options[:connect_timeout] = @request.open_timeout if @request.open_timeout
|
76
77
|
|
77
78
|
options[:proxy] = proxy_options if @request.proxy
|
78
79
|
|
data/lib/httpi/adapter/excon.rb
CHANGED
@@ -42,7 +42,7 @@ module HTTPI
|
|
42
42
|
opts = {
|
43
43
|
:host => url.host,
|
44
44
|
:path => url.path,
|
45
|
-
:port => url.port
|
45
|
+
:port => url.port,
|
46
46
|
:query => url.query,
|
47
47
|
:scheme => url.scheme,
|
48
48
|
:headers => @request.headers,
|
@@ -58,6 +58,7 @@ module HTTPI
|
|
58
58
|
opts[:user], opts[:password] = *@request.auth.credentials if @request.auth.basic?
|
59
59
|
opts[:connect_timeout] = @request.open_timeout if @request.open_timeout
|
60
60
|
opts[:read_timeout] = @request.read_timeout if @request.read_timeout
|
61
|
+
opts[:write_timeout] = @request.write_timeout if @request.write_timeout
|
61
62
|
opts[:response_block] = @request.on_body if @request.on_body
|
62
63
|
opts[:proxy] = @request.proxy if @request.proxy
|
63
64
|
|
data/lib/httpi/adapter/http.rb
CHANGED
@@ -73,6 +73,12 @@ module HTTPI
|
|
73
73
|
client = client.via(@request.proxy.host, @request.proxy.port, @request.proxy.user, @request.proxy.password)
|
74
74
|
end
|
75
75
|
|
76
|
+
timeouts = {}
|
77
|
+
timeouts[:connect] = @request.open_timeout if @request.open_timeout
|
78
|
+
timeouts[:read] = @request.read_timeout if @request.read_timeout
|
79
|
+
timeouts[:write] = @request.write_timeout if @request.write_timeout
|
80
|
+
client = client.timeout(timeouts) if timeouts.any?
|
81
|
+
|
76
82
|
client.headers(@request.headers)
|
77
83
|
end
|
78
84
|
end
|
@@ -45,6 +45,7 @@ module HTTPI
|
|
45
45
|
@client.proxy = @request.proxy if @request.proxy
|
46
46
|
@client.connect_timeout = @request.open_timeout if @request.open_timeout
|
47
47
|
@client.receive_timeout = @request.read_timeout if @request.read_timeout
|
48
|
+
@client.send_timeout = @request.write_timeout if @request.write_timeout
|
48
49
|
end
|
49
50
|
|
50
51
|
def setup_auth
|
@@ -155,6 +155,13 @@ module HTTPI
|
|
155
155
|
@client.use_ssl = @request.ssl?
|
156
156
|
@client.open_timeout = @request.open_timeout if @request.open_timeout
|
157
157
|
@client.read_timeout = @request.read_timeout if @request.read_timeout
|
158
|
+
if @request.write_timeout
|
159
|
+
if @client.respond_to?(:write_timeout=) # Expected to appear in Ruby 2.6
|
160
|
+
@client.write_timeout = @request.write_timeout
|
161
|
+
else
|
162
|
+
raise NotSupportedError, "Net::HTTP supports write_timeout starting from Ruby 2.6"
|
163
|
+
end
|
164
|
+
end
|
158
165
|
end
|
159
166
|
|
160
167
|
def setup_ssl_auth
|
@@ -32,6 +32,7 @@ module HTTPI
|
|
32
32
|
|
33
33
|
@client.open_timeout = @request.open_timeout if @request.open_timeout
|
34
34
|
@client.read_timeout = @request.read_timeout if @request.read_timeout
|
35
|
+
raise NotSupportedError, "Net::HTTP::Persistent does not support write_timeout" if @request.write_timeout
|
35
36
|
end
|
36
37
|
|
37
38
|
def thread_key
|
data/lib/httpi/auth/ssl.rb
CHANGED
@@ -42,7 +42,7 @@ module HTTPI
|
|
42
42
|
# Accessor for the ca_path to validate SSL certificates.
|
43
43
|
attr_accessor :ca_cert_path
|
44
44
|
|
45
|
-
#
|
45
|
+
# Certificate store holds trusted CA certificates used to verify peer certificates.
|
46
46
|
attr_accessor :cert_store
|
47
47
|
|
48
48
|
# Returns the cert type to validate SSL certificates PEM|DER.
|
data/lib/httpi/request.rb
CHANGED
@@ -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, :redirect_limit, :query]
|
14
|
+
ATTRIBUTES = [:url, :proxy, :headers, :body, :open_timeout, :read_timeout, :write_timeout, :follow_redirect, :redirect_limit, :query]
|
15
15
|
|
16
16
|
# Accepts a Hash of +args+ to mass assign attributes and authentication credentials.
|
17
17
|
def initialize(args = {})
|
@@ -90,7 +90,7 @@ module HTTPI
|
|
90
90
|
headers["Cookie"] = cookies if cookies
|
91
91
|
end
|
92
92
|
|
93
|
-
attr_accessor :open_timeout, :read_timeout
|
93
|
+
attr_accessor :open_timeout, :read_timeout, :write_timeout
|
94
94
|
attr_reader :body
|
95
95
|
|
96
96
|
# Sets a body request given a String or a Hash.
|
data/lib/httpi/version.rb
CHANGED
@@ -146,29 +146,36 @@ unless RUBY_PLATFORM =~ /java/
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe "
|
149
|
+
describe "timeout_ms" do
|
150
150
|
it "is not set unless it's specified" do
|
151
|
-
curb.expects(:
|
151
|
+
curb.expects(:timeout_ms=).never
|
152
152
|
adapter.request(:get)
|
153
153
|
end
|
154
154
|
|
155
|
-
it "is set if specified" do
|
155
|
+
it "is set if specified read_timeout" do
|
156
156
|
request.read_timeout = 30
|
157
|
-
curb.expects(:
|
157
|
+
curb.expects(:timeout_ms=).with(30_000)
|
158
|
+
|
159
|
+
adapter.request(:get)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "is set if specified write_timeout" do
|
163
|
+
request.write_timeout = 30
|
164
|
+
curb.expects(:timeout_ms=).with(30_000)
|
158
165
|
|
159
166
|
adapter.request(:get)
|
160
167
|
end
|
161
168
|
end
|
162
169
|
|
163
|
-
describe "
|
170
|
+
describe "connect_timeout_ms" do
|
164
171
|
it "is not set unless it's specified" do
|
165
|
-
curb.expects(:
|
172
|
+
curb.expects(:connect_timeout_ms=).never
|
166
173
|
adapter.request(:get)
|
167
174
|
end
|
168
175
|
|
169
176
|
it "is set if specified" do
|
170
177
|
request.open_timeout = 30
|
171
|
-
curb.expects(:
|
178
|
+
curb.expects(:connect_timeout_ms=).with(30_000)
|
172
179
|
|
173
180
|
adapter.request(:get)
|
174
181
|
end
|
@@ -89,15 +89,12 @@ begin
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "sets host, port and authorization" do
|
92
|
-
url =
|
93
|
-
|
92
|
+
url = "http://example.com:80"
|
94
93
|
connection_options = {
|
95
|
-
:
|
96
|
-
|
97
|
-
|
98
|
-
:
|
99
|
-
:port => 443,
|
100
|
-
:authorization => ['username', 'password']
|
94
|
+
:proxy => {
|
95
|
+
:host => "proxy-host.com",
|
96
|
+
:port => 443,
|
97
|
+
:authorization => ["username", "password"]
|
101
98
|
}
|
102
99
|
}
|
103
100
|
|
@@ -111,8 +108,8 @@ begin
|
|
111
108
|
it "is passed as a connection option" do
|
112
109
|
request.open_timeout = 30
|
113
110
|
|
114
|
-
url =
|
115
|
-
connection_options = { :
|
111
|
+
url = "http://example.com:80"
|
112
|
+
connection_options = { connect_timeout: 30 }
|
116
113
|
|
117
114
|
EventMachine::HttpRequest.expects(:new).with(url, connection_options)
|
118
115
|
|
@@ -121,11 +118,22 @@ begin
|
|
121
118
|
end
|
122
119
|
|
123
120
|
describe "receive_timeout" do
|
124
|
-
it "is passed as a connection option" do
|
121
|
+
it "is passed as a connection option (when read_timeout specified)" do
|
125
122
|
request.read_timeout = 60
|
126
123
|
|
127
|
-
url =
|
128
|
-
connection_options = { :
|
124
|
+
url = "http://example.com:80"
|
125
|
+
connection_options = { inactivity_timeout: 60 }
|
126
|
+
|
127
|
+
EventMachine::HttpRequest.expects(:new).with(url, connection_options)
|
128
|
+
|
129
|
+
adapter
|
130
|
+
end
|
131
|
+
|
132
|
+
it "is passed as a connection option (when write_timeout specified)" do
|
133
|
+
request.write_timeout = 60
|
134
|
+
|
135
|
+
url = "http://example.com:80"
|
136
|
+
connection_options = { inactivity_timeout: 60 }
|
129
137
|
|
130
138
|
EventMachine::HttpRequest.expects(:new).with(url, connection_options)
|
131
139
|
|
@@ -1,124 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
it "executes GET requests" do
|
26
|
-
response = HTTPI.get(@server.url, adapter)
|
27
|
-
expect(response.body).to eq("get")
|
28
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "executes POST requests" do
|
32
|
-
response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
|
33
|
-
expect(response.body).to eq("post")
|
34
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "executes HEAD requests" do
|
38
|
-
response = HTTPI.head(@server.url, adapter)
|
39
|
-
expect(response.code).to eq(200)
|
40
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "executes PUT requests" do
|
44
|
-
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
45
|
-
expect(response.body).to eq("put")
|
46
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "executes DELETE requests" do
|
50
|
-
response = HTTPI.delete(@server.url, adapter)
|
51
|
-
expect(response.body).to eq("delete")
|
52
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "supports basic authentication" do
|
56
|
-
request = HTTPI::Request.new(@server.url + "basic-auth")
|
57
|
-
request.auth.basic("admin", "secret")
|
58
|
-
|
59
|
-
response = HTTPI.get(request, adapter)
|
60
|
-
expect(response.body).to eq("basic-auth")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "does not support ntlm authentication" do
|
64
|
-
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
65
|
-
request.auth.ntlm("tester", "vReqSoafRe5O")
|
66
|
-
|
67
|
-
expect { HTTPI.get(request, adapter) }.
|
68
|
-
to raise_error(HTTPI::NotSupportedError, /does not support NTLM authentication/)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "supports disabling verify mode" do
|
72
|
-
request = HTTPI::Request.new(@server.url)
|
73
|
-
request.auth.ssl.verify_mode = :none
|
74
|
-
adapter_class = HTTPI::Adapter.load(adapter).new(request)
|
75
|
-
expect(adapter_class.client.data[:ssl_verify_peer]).to eq(false)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# it does not support digest auth
|
80
|
-
|
81
|
-
if RUBY_PLATFORM =~ /java/
|
82
|
-
pending "Puma Server complains: SSL not supported on JRuby"
|
83
|
-
else
|
84
|
-
context "https requests" do
|
85
|
-
before :all do
|
86
|
-
@server = IntegrationServer.run(:ssl => true)
|
87
|
-
end
|
88
|
-
after :all do
|
89
|
-
@server.stop
|
90
|
-
end
|
91
|
-
|
92
|
-
# it does not raise when no certificate was set up
|
93
|
-
it "works when no client cert is specified" do
|
94
|
-
request = HTTPI::Request.new(@server.url)
|
95
|
-
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
96
|
-
|
97
|
-
response = HTTPI.get(request, adapter)
|
98
|
-
expect(response.body).to eq("get")
|
99
|
-
end
|
100
|
-
|
101
|
-
it "works with client cert and key provided as file path" do
|
102
|
-
request = HTTPI::Request.new(@server.url)
|
103
|
-
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
104
|
-
request.auth.ssl.cert_file = "spec/fixtures/client_cert.pem"
|
105
|
-
request.auth.ssl.cert_key_file = "spec/fixtures/client_key.pem"
|
106
|
-
|
107
|
-
response = HTTPI.get(request, adapter)
|
108
|
-
expect(response.body).to eq("get")
|
109
|
-
end
|
110
|
-
|
111
|
-
it "works with client cert and key set directly" do
|
112
|
-
request = HTTPI::Request.new(@server.url)
|
113
|
-
|
114
|
-
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
115
|
-
request.auth.ssl.cert = OpenSSL::X509::Certificate.new File.open("spec/fixtures/client_cert.pem").read
|
116
|
-
request.auth.ssl.cert_key = OpenSSL::PKey.read File.open("spec/fixtures/client_key.pem").read
|
117
|
-
|
118
|
-
response = HTTPI.get(request, adapter)
|
119
|
-
expect(response.body).to eq("get")
|
2
|
+
require "httpi/adapter/excon"
|
3
|
+
require "httpi/request"
|
4
|
+
|
5
|
+
begin
|
6
|
+
HTTPI::Adapter.load_adapter(:excon)
|
7
|
+
|
8
|
+
describe HTTPI::Adapter::Excon do
|
9
|
+
let(:adapter) { HTTPI::Adapter::Excon.new(request) }
|
10
|
+
let(:request) { HTTPI::Request.new("http://example.com") }
|
11
|
+
|
12
|
+
describe "settings" do
|
13
|
+
describe "connect_timeout, read_timeout, write_timeout" do
|
14
|
+
it "are passed as connection options" do
|
15
|
+
request.open_timeout = 30
|
16
|
+
request.read_timeout = 40
|
17
|
+
request.write_timeout = 50
|
18
|
+
|
19
|
+
expect(adapter.client.data).to include(
|
20
|
+
connect_timeout: 30,
|
21
|
+
read_timeout: 40,
|
22
|
+
write_timeout: 50
|
23
|
+
)
|
24
|
+
end
|
120
25
|
end
|
121
26
|
end
|
122
27
|
end
|
123
|
-
|
124
28
|
end
|
@@ -1,101 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
it "executes GET requests" do
|
26
|
-
response = HTTPI.get(@server.url, adapter)
|
27
|
-
expect(response.body).to eq("get")
|
28
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "executes POST requests" do
|
32
|
-
response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
|
33
|
-
expect(response.body).to eq("post")
|
34
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "executes HEAD requests" do
|
38
|
-
response = HTTPI.head(@server.url, adapter)
|
39
|
-
expect(response.code).to eq(200)
|
40
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "executes PUT requests" do
|
44
|
-
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
45
|
-
expect(response.body).to eq("put")
|
46
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "executes DELETE requests" do
|
50
|
-
response = HTTPI.delete(@server.url, adapter)
|
51
|
-
expect(response.body).to eq("delete")
|
52
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "supports basic authentication" do
|
56
|
-
request = HTTPI::Request.new(@server.url + "basic-auth")
|
57
|
-
request.auth.basic("admin", "secret")
|
58
|
-
|
59
|
-
response = HTTPI.get(request, adapter)
|
60
|
-
expect(response.body).to eq("basic-auth")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "does not support digest authentication" do
|
64
|
-
request = HTTPI::Request.new(@server.url + "digest-auth")
|
65
|
-
request.auth.digest("admin", "secret")
|
66
|
-
|
67
|
-
expect { HTTPI.get(request, adapter) }.
|
68
|
-
to raise_error(HTTPI::NotSupportedError, /does not support HTTP digest authentication/)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "does not support ntlm authentication" do
|
72
|
-
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
73
|
-
request.auth.ntlm("tester", "vReqSoafRe5O")
|
74
|
-
|
75
|
-
expect { HTTPI.get(request, adapter) }.
|
76
|
-
to raise_error(HTTPI::NotSupportedError, /does not support NTLM digest authentication/)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
if RUBY_PLATFORM =~ /java/
|
81
|
-
pending "Puma Server complains: SSL not supported on JRuby"
|
82
|
-
else
|
83
|
-
context "https requests" do
|
84
|
-
before :all do
|
85
|
-
@server = IntegrationServer.run(:ssl => true)
|
86
|
-
end
|
87
|
-
after :all do
|
88
|
-
@server.stop
|
89
|
-
end
|
90
|
-
|
91
|
-
it "works when set up properly" do
|
92
|
-
request = HTTPI::Request.new(@server.url)
|
93
|
-
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
94
|
-
|
95
|
-
response = HTTPI.get(request, adapter)
|
96
|
-
expect(response.body).to eq("get")
|
2
|
+
require "httpi/adapter/http"
|
3
|
+
require "httpi/request"
|
4
|
+
|
5
|
+
begin
|
6
|
+
HTTPI::Adapter.load_adapter(:http)
|
7
|
+
|
8
|
+
describe HTTPI::Adapter::HTTP do
|
9
|
+
let(:adapter) { HTTPI::Adapter::HTTP.new(request) }
|
10
|
+
let(:request) { HTTPI::Request.new("http://example.com") }
|
11
|
+
|
12
|
+
describe "settings" do
|
13
|
+
describe "connect_timeout, read_timeout, write_timeout" do
|
14
|
+
it "are being set on the client" do
|
15
|
+
request.open_timeout = 30
|
16
|
+
request.read_timeout = 40
|
17
|
+
request.write_timeout = 50
|
18
|
+
|
19
|
+
expect(adapter.client.default_options.timeout_options).to eq(
|
20
|
+
connect_timeout: 30,
|
21
|
+
read_timeout: 40,
|
22
|
+
write_timeout: 50
|
23
|
+
)
|
24
|
+
end
|
97
25
|
end
|
98
26
|
end
|
99
27
|
end
|
100
|
-
|
101
28
|
end
|