httpi 2.4.1 → 3.0.0
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 +5 -5
- data/.github/workflows/development.yml +48 -0
- data/CHANGELOG.md +45 -0
- data/Gemfile +10 -5
- data/README.md +20 -16
- data/Rakefile +5 -3
- data/UPDATING.md +7 -0
- data/httpi.gemspec +6 -7
- data/lib/httpi/adapter/curb.rb +8 -2
- data/lib/httpi/adapter/em_http.rb +5 -4
- data/lib/httpi/adapter/excon.rb +17 -5
- data/lib/httpi/adapter/http.rb +15 -2
- data/lib/httpi/adapter/httpclient.rb +16 -4
- data/lib/httpi/adapter/net_http.rb +42 -16
- data/lib/httpi/adapter/net_http_persistent.rb +6 -2
- data/lib/httpi/adapter/rack.rb +13 -6
- data/lib/httpi/auth/ssl.rb +68 -3
- data/lib/httpi/logger.rb +6 -1
- data/lib/httpi/request.rb +12 -5
- data/lib/httpi/response.rb +2 -0
- data/lib/httpi/version.rb +1 -1
- data/lib/httpi.rb +4 -4
- data/spec/fixtures/client_cert.pem +18 -14
- data/spec/fixtures/client_key.pem +25 -13
- data/spec/httpi/adapter/curb_spec.rb +36 -10
- data/spec/httpi/adapter/em_http_spec.rb +23 -21
- data/spec/httpi/adapter/excon_spec.rb +28 -90
- data/spec/httpi/adapter/http_spec.rb +23 -96
- data/spec/httpi/adapter/httpclient_spec.rb +46 -4
- data/spec/httpi/adapter/net_http_persistent_spec.rb +31 -81
- data/spec/httpi/adapter/net_http_spec.rb +39 -99
- data/spec/httpi/adapter/rack_spec.rb +6 -8
- data/spec/httpi/auth/ssl_spec.rb +49 -1
- data/spec/httpi/httpi_spec.rb +16 -4
- data/spec/httpi/request_spec.rb +5 -0
- data/spec/integration/curb_spec.rb +20 -0
- data/spec/integration/em_http_spec.rb +19 -2
- data/spec/integration/excon_spec.rb +174 -0
- data/spec/integration/fixtures/ca_all.pem +17 -42
- data/spec/integration/fixtures/server.cert +17 -17
- data/spec/integration/fixtures/server.key +25 -13
- data/spec/integration/http_spec.rb +156 -0
- data/spec/integration/httpclient_spec.rb +20 -0
- data/spec/integration/net_http_persistent_spec.rb +34 -2
- data/spec/integration/net_http_spec.rb +144 -1
- data/spec/integration/support/application.rb +4 -2
- data/spec/integration/support/server.rb +1 -2
- data/spec/spec_helper.rb +0 -2
- metadata +31 -29
- data/.travis.yml +0 -8
@@ -3,8 +3,8 @@ require "integration/support/server"
|
|
3
3
|
|
4
4
|
describe HTTPI::Adapter::EmHttpRequest do
|
5
5
|
|
6
|
-
# em_http is not supported on
|
7
|
-
unless
|
6
|
+
# em_http is not supported on java
|
7
|
+
unless RUBY_PLATFORM =~ /java/
|
8
8
|
require "em-synchrony"
|
9
9
|
|
10
10
|
subject(:adapter) { :em_http }
|
@@ -42,6 +42,23 @@ describe HTTPI::Adapter::EmHttpRequest do
|
|
42
42
|
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
43
43
|
end
|
44
44
|
|
45
|
+
if RUBY_PLATFORM =~ /java/
|
46
|
+
pending <<-MSG
|
47
|
+
It seems like JRuby is missing support for inactivity timeout! See related issues on GitHub:
|
48
|
+
- https://github.com/eventmachine/eventmachine/issues/155
|
49
|
+
- https://github.com/eventmachine/eventmachine/pull/312
|
50
|
+
MSG
|
51
|
+
else
|
52
|
+
it "it supports read timeout" do
|
53
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
54
|
+
request.read_timeout = 0.5 # seconds
|
55
|
+
|
56
|
+
expect do
|
57
|
+
HTTPI.get(request, adapter)
|
58
|
+
end.to raise_exception(HTTPI::TimeoutError)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
45
62
|
it "executes GET requests" do
|
46
63
|
response = HTTPI.get(@server.url, adapter)
|
47
64
|
expect(response.body).to eq("get")
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "integration/support/server"
|
3
|
+
|
4
|
+
describe HTTPI::Adapter::Excon do
|
5
|
+
|
6
|
+
subject(:adapter) { :excon }
|
7
|
+
|
8
|
+
context "http requests" do
|
9
|
+
before :all do
|
10
|
+
@server = IntegrationServer.run
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
@server.stop
|
15
|
+
end
|
16
|
+
|
17
|
+
it "sends and receives HTTP headers" do
|
18
|
+
request = HTTPI::Request.new(@server.url + "x-header")
|
19
|
+
request.headers["X-Header"] = "HTTPI"
|
20
|
+
|
21
|
+
response = HTTPI.get(request, adapter)
|
22
|
+
expect(response.body).to include("HTTPI")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it supports headers with multiple values" do
|
26
|
+
request = HTTPI::Request.new(@server.url + "cookies")
|
27
|
+
|
28
|
+
response = HTTPI.get(request, adapter)
|
29
|
+
cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
|
30
|
+
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "it supports read timeout" do
|
34
|
+
require "excon"
|
35
|
+
|
36
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
37
|
+
request.read_timeout = 0.5 # seconds
|
38
|
+
|
39
|
+
expect do
|
40
|
+
HTTPI.get(request, adapter)
|
41
|
+
end.to raise_exception(Excon::Error::Timeout)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "executes GET requests" do
|
45
|
+
response = HTTPI.get(@server.url, adapter)
|
46
|
+
expect(response.body).to eq("get")
|
47
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "executes POST requests" do
|
51
|
+
response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
|
52
|
+
expect(response.body).to eq("post")
|
53
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "executes HEAD requests" do
|
57
|
+
response = HTTPI.head(@server.url, adapter)
|
58
|
+
expect(response.code).to eq(200)
|
59
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "executes PUT requests" do
|
63
|
+
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
64
|
+
expect(response.body).to eq("put")
|
65
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "executes DELETE requests" do
|
69
|
+
response = HTTPI.delete(@server.url, adapter)
|
70
|
+
expect(response.body).to eq("delete")
|
71
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "supports basic authentication" do
|
75
|
+
request = HTTPI::Request.new(@server.url + "basic-auth")
|
76
|
+
request.auth.basic("admin", "secret")
|
77
|
+
|
78
|
+
response = HTTPI.get(request, adapter)
|
79
|
+
expect(response.body).to eq("basic-auth")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "does not support ntlm authentication" do
|
83
|
+
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
84
|
+
request.auth.ntlm("tester", "vReqSoafRe5O")
|
85
|
+
|
86
|
+
expect { HTTPI.get(request, adapter) }.
|
87
|
+
to raise_error(HTTPI::NotSupportedError, /does not support NTLM authentication/)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "supports disabling verify mode" do
|
91
|
+
request = HTTPI::Request.new(@server.url)
|
92
|
+
request.auth.ssl.verify_mode = :none
|
93
|
+
adapter_class = HTTPI::Adapter.load(adapter).new(request)
|
94
|
+
expect(adapter_class.client.data[:ssl_verify_peer]).to eq(false)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "supports chunked response" do
|
98
|
+
request = HTTPI::Request.new(@server.url)
|
99
|
+
res = ""
|
100
|
+
request.on_body do |body|
|
101
|
+
res += body
|
102
|
+
end
|
103
|
+
response = HTTPI.post(request, adapter)
|
104
|
+
expect(res).to eq("post")
|
105
|
+
expect(response.body).to eq("")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
if RUBY_PLATFORM =~ /java/
|
110
|
+
pending "Puma Server complains: SSL not supported on JRuby"
|
111
|
+
else
|
112
|
+
context "https requests" do
|
113
|
+
before :all do
|
114
|
+
@server = IntegrationServer.run(:ssl => true)
|
115
|
+
end
|
116
|
+
after :all do
|
117
|
+
@server.stop
|
118
|
+
end
|
119
|
+
|
120
|
+
it "raises when no certificate was set up" do
|
121
|
+
expect { HTTPI.post(@server.url, "", adapter) }.to raise_error(HTTPI::SSLError)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "works when set up properly" do
|
125
|
+
request = HTTPI::Request.new(@server.url)
|
126
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
127
|
+
|
128
|
+
response = HTTPI.get(request, adapter)
|
129
|
+
expect(response.body).to eq("get")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "works with min_version/max_version" do
|
133
|
+
request = HTTPI::Request.new(@server.url)
|
134
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
135
|
+
request.auth.ssl.min_version = :TLS1_2
|
136
|
+
request.auth.ssl.max_version = :TLS1_2
|
137
|
+
|
138
|
+
response = HTTPI.get(request, adapter)
|
139
|
+
expect(response.body).to eq("get")
|
140
|
+
end
|
141
|
+
|
142
|
+
it "works with client cert and key provided as file path" do
|
143
|
+
request = HTTPI::Request.new(@server.url)
|
144
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
145
|
+
request.auth.ssl.cert_file = "spec/fixtures/client_cert.pem"
|
146
|
+
request.auth.ssl.cert_key_file = "spec/fixtures/client_key.pem"
|
147
|
+
|
148
|
+
response = HTTPI.get(request, adapter)
|
149
|
+
expect(response.body).to eq("get")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "works with client cert and key set directly" do
|
153
|
+
request = HTTPI::Request.new(@server.url)
|
154
|
+
|
155
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
156
|
+
request.auth.ssl.cert = OpenSSL::X509::Certificate.new File.open("spec/fixtures/client_cert.pem").read
|
157
|
+
request.auth.ssl.cert_key = OpenSSL::PKey.read File.open("spec/fixtures/client_key.pem").read
|
158
|
+
|
159
|
+
response = HTTPI.get(request, adapter)
|
160
|
+
expect(response.body).to eq("get")
|
161
|
+
end
|
162
|
+
|
163
|
+
it "works with ciphers" do
|
164
|
+
request = HTTPI::Request.new(@server.url)
|
165
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
166
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
167
|
+
|
168
|
+
response = HTTPI.get(request, adapter)
|
169
|
+
expect(response.body).to eq("get")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -1,44 +1,19 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
|
20
|
-
PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
|
21
|
-
PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
|
22
|
-
d/xgcK06UVQRL/HbEYGiQL056mc=
|
23
|
-
-----END CERTIFICATE-----
|
24
|
-
-----BEGIN CERTIFICATE-----
|
25
|
-
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
26
|
-
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
27
|
-
DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1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ucqpA1HOftp
|
21
|
+
z5isGq3ctdXaxP8YsLuPcw1RAoGAXZx0W70ryy2JAJidbd55Hiq17ktOHumOzO2x
|
22
|
+
Qw+Lt9Lz2NqlJnXxCruVC9miwUJ3hPl93/iN21hRk6GJ7qFxDcda7nz3C5LTCzZd
|
23
|
+
LR4fKfTTxBKGPb6QHpDpbmpRmZECHqZOjCzoVMyBCf2JST/VUbkWqKLso4uhIidb
|
24
|
+
yRCbSmECgYEAp+IuwpnMxVPxP52/xPFVcAxH2pDfmn5TJLJCNuKEUAS9ncZuz7rh
|
25
|
+
jJxtbC4AoGsS0+TdxnlMBvBpZE3QddQmjvey77yu/OvRUX2m/J/d+I2duTaHGR9Z
|
26
|
+
9VMxtlFY+DbDkJI2HVVxu5XfLKMJSEsMza8K64Ntx3XY3dJLCHrR1EY=
|
15
27
|
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "integration/support/server"
|
3
|
+
|
4
|
+
describe HTTPI::Adapter::HTTP do
|
5
|
+
|
6
|
+
subject(:adapter) { :http }
|
7
|
+
|
8
|
+
context "http requests" do
|
9
|
+
before :all do
|
10
|
+
@server = IntegrationServer.run
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
@server.stop
|
15
|
+
end
|
16
|
+
|
17
|
+
it "sends and receives HTTP headers" do
|
18
|
+
request = HTTPI::Request.new(@server.url + "x-header")
|
19
|
+
request.headers["X-Header"] = "HTTPI"
|
20
|
+
|
21
|
+
response = HTTPI.get(request, adapter)
|
22
|
+
expect(response.body).to include("HTTPI")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it supports headers with multiple values" do
|
26
|
+
request = HTTPI::Request.new(@server.url + "cookies")
|
27
|
+
|
28
|
+
response = HTTPI.get(request, adapter)
|
29
|
+
cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
|
30
|
+
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "it supports read timeout" do
|
34
|
+
require "http"
|
35
|
+
|
36
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
37
|
+
request.read_timeout = 0.5 # seconds
|
38
|
+
|
39
|
+
expect do
|
40
|
+
HTTPI.get(request, adapter)
|
41
|
+
end.to raise_exception(HTTP::TimeoutError)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
it "executes GET requests" do
|
46
|
+
response = HTTPI.get(@server.url, adapter)
|
47
|
+
expect(response.body).to eq("get")
|
48
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "executes POST requests" do
|
52
|
+
response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
|
53
|
+
expect(response.body).to eq("post")
|
54
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "executes HEAD requests" do
|
58
|
+
response = HTTPI.head(@server.url, adapter)
|
59
|
+
expect(response.code).to eq(200)
|
60
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "executes PUT requests" do
|
64
|
+
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
65
|
+
expect(response.body).to eq("put")
|
66
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "executes DELETE requests" do
|
70
|
+
response = HTTPI.delete(@server.url, adapter)
|
71
|
+
expect(response.body).to eq("delete")
|
72
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "supports basic authentication" do
|
76
|
+
request = HTTPI::Request.new(@server.url + "basic-auth")
|
77
|
+
request.auth.basic("admin", "secret")
|
78
|
+
|
79
|
+
response = HTTPI.get(request, adapter)
|
80
|
+
expect(response.body).to eq("basic-auth")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "does not support digest authentication" do
|
84
|
+
request = HTTPI::Request.new(@server.url + "digest-auth")
|
85
|
+
request.auth.digest("admin", "secret")
|
86
|
+
|
87
|
+
expect { HTTPI.get(request, adapter) }.
|
88
|
+
to raise_error(HTTPI::NotSupportedError, /does not support HTTP digest authentication/)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "does not support ntlm authentication" do
|
92
|
+
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
93
|
+
request.auth.ntlm("tester", "vReqSoafRe5O")
|
94
|
+
|
95
|
+
expect { HTTPI.get(request, adapter) }.
|
96
|
+
to raise_error(HTTPI::NotSupportedError, /does not support NTLM digest authentication/)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "supports chunked response" do
|
100
|
+
skip("Needs investigation")
|
101
|
+
request = HTTPI::Request.new(@server.url)
|
102
|
+
res = ""
|
103
|
+
request.on_body do |body|
|
104
|
+
res += body
|
105
|
+
end
|
106
|
+
response = HTTPI.post(request, adapter)
|
107
|
+
expect(res).to eq("post")
|
108
|
+
expect(response.body).to eq("")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
if RUBY_PLATFORM =~ /java/
|
113
|
+
pending "Puma Server complains: SSL not supported on JRuby"
|
114
|
+
else
|
115
|
+
context "https requests" do
|
116
|
+
before :all do
|
117
|
+
@server = IntegrationServer.run(:ssl => true)
|
118
|
+
end
|
119
|
+
after :all do
|
120
|
+
@server.stop
|
121
|
+
end
|
122
|
+
|
123
|
+
it "raises when no certificate was set up" do
|
124
|
+
expect { HTTPI.post(@server.url, "", adapter) }.to raise_error(HTTPI::SSLError)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "works when set up properly" do
|
128
|
+
request = HTTPI::Request.new(@server.url)
|
129
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
130
|
+
|
131
|
+
response = HTTPI.get(request, adapter)
|
132
|
+
expect(response.body).to eq("get")
|
133
|
+
end
|
134
|
+
|
135
|
+
it "works with min_version/max_version" do
|
136
|
+
request = HTTPI::Request.new(@server.url)
|
137
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
138
|
+
request.auth.ssl.min_version = :TLS1_2
|
139
|
+
request.auth.ssl.max_version = :TLS1_2
|
140
|
+
|
141
|
+
response = HTTPI.get(request, adapter)
|
142
|
+
expect(response.body).to eq("get")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "works with ciphers" do
|
146
|
+
request = HTTPI::Request.new(@server.url)
|
147
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
148
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
149
|
+
|
150
|
+
response = HTTPI.get(request, adapter)
|
151
|
+
expect(response.body).to eq("get")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -30,6 +30,17 @@ describe HTTPI::Adapter::HTTPClient do
|
|
30
30
|
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "it supports read timeout" do
|
34
|
+
require "httpclient"
|
35
|
+
|
36
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
37
|
+
request.read_timeout = 0.5 # seconds
|
38
|
+
|
39
|
+
expect do
|
40
|
+
HTTPI.get(request, adapter)
|
41
|
+
end.to raise_exception(HTTPClient::ReceiveTimeoutError)
|
42
|
+
end
|
43
|
+
|
33
44
|
it "executes GET requests" do
|
34
45
|
response = HTTPI.get(@server.url, adapter)
|
35
46
|
expect(response.body).to eq("get")
|
@@ -110,6 +121,15 @@ describe HTTPI::Adapter::HTTPClient do
|
|
110
121
|
response = HTTPI.get(request, adapter)
|
111
122
|
expect(response.body).to eq("get")
|
112
123
|
end
|
124
|
+
|
125
|
+
it "works with ciphers" do
|
126
|
+
request = HTTPI::Request.new(@server.url)
|
127
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
128
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
129
|
+
|
130
|
+
response = HTTPI.get(request, adapter)
|
131
|
+
expect(response.body).to eq("get")
|
132
|
+
end
|
113
133
|
end
|
114
134
|
end
|
115
135
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "integration/support/server"
|
3
|
+
require "net/http/persistent"
|
3
4
|
|
4
|
-
describe HTTPI::Adapter::
|
5
|
+
describe HTTPI::Adapter::NetHTTPPersistent do
|
5
6
|
|
6
7
|
subject(:adapter) { :net_http_persistent }
|
7
8
|
|
@@ -30,6 +31,17 @@ describe HTTPI::Adapter::NetHTTP do
|
|
30
31
|
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
31
32
|
end
|
32
33
|
|
34
|
+
it "it supports read timeout" do
|
35
|
+
require "net/http/persistent"
|
36
|
+
|
37
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
38
|
+
request.read_timeout = 0.5 # seconds
|
39
|
+
|
40
|
+
expect do
|
41
|
+
HTTPI.get(request, adapter)
|
42
|
+
end.to raise_exception(Net::ReadTimeout)
|
43
|
+
end
|
44
|
+
|
33
45
|
it "executes GET requests" do
|
34
46
|
response = HTTPI.get(@server.url, adapter)
|
35
47
|
expect(response.body).to eq("get")
|
@@ -37,7 +49,9 @@ describe HTTPI::Adapter::NetHTTP do
|
|
37
49
|
end
|
38
50
|
|
39
51
|
it "executes POST requests" do
|
40
|
-
|
52
|
+
request = HTTPI::Request.new(url: @server.url, body: "<some>xml</some>")
|
53
|
+
|
54
|
+
response = HTTPI.post(request, adapter)
|
41
55
|
expect(response.body).to eq("post")
|
42
56
|
expect(response.headers["Content-Type"]).to eq("text/plain")
|
43
57
|
end
|
@@ -68,6 +82,14 @@ describe HTTPI::Adapter::NetHTTP do
|
|
68
82
|
expect(response.body).to eq("basic-auth")
|
69
83
|
end
|
70
84
|
|
85
|
+
it "does not support ntlm authentication" do
|
86
|
+
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
87
|
+
request.auth.ntlm("tester", "vReqSoafRe5O")
|
88
|
+
|
89
|
+
expect { HTTPI.get(request, adapter) }.
|
90
|
+
to raise_error(HTTPI::NotSupportedError, /does not support NTLM authentication/)
|
91
|
+
end
|
92
|
+
|
71
93
|
# it does not support digest authentication
|
72
94
|
|
73
95
|
it "supports chunked response" do
|
@@ -89,6 +111,7 @@ describe HTTPI::Adapter::NetHTTP do
|
|
89
111
|
before :all do
|
90
112
|
@server = IntegrationServer.run(:ssl => true)
|
91
113
|
end
|
114
|
+
|
92
115
|
after :all do
|
93
116
|
@server.stop
|
94
117
|
end
|
@@ -101,6 +124,15 @@ describe HTTPI::Adapter::NetHTTP do
|
|
101
124
|
response = HTTPI.get(request, adapter)
|
102
125
|
expect(response.body).to eq("get")
|
103
126
|
end
|
127
|
+
|
128
|
+
it "works with ciphers" do
|
129
|
+
request = HTTPI::Request.new(@server.url)
|
130
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
131
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
132
|
+
|
133
|
+
response = HTTPI.get(request, adapter)
|
134
|
+
expect(response.body).to eq("get")
|
135
|
+
end
|
104
136
|
end
|
105
137
|
end
|
106
138
|
|