httpi 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/httpi/version.rb +1 -1
  4. metadata +2 -50
  5. data/.devcontainer/devcontainer.json +0 -22
  6. data/.github/workflows/development.yml +0 -49
  7. data/.gitignore +0 -11
  8. data/.rspec +0 -1
  9. data/Gemfile +0 -22
  10. data/Rakefile +0 -18
  11. data/httpi.gemspec +0 -40
  12. data/spec/fixtures/attachment.gif +0 -0
  13. data/spec/fixtures/client_cert.pem +0 -20
  14. data/spec/fixtures/client_key.pem +0 -27
  15. data/spec/fixtures/xml.gz +0 -0
  16. data/spec/fixtures/xml.xml +0 -10
  17. data/spec/fixtures/xml_dime.dime +0 -0
  18. data/spec/fixtures/xml_dime.xml +0 -1
  19. data/spec/httpi/adapter/base_spec.rb +0 -23
  20. data/spec/httpi/adapter/curb_spec.rb +0 -351
  21. data/spec/httpi/adapter/em_http_spec.rb +0 -180
  22. data/spec/httpi/adapter/excon_spec.rb +0 -34
  23. data/spec/httpi/adapter/http_spec.rb +0 -28
  24. data/spec/httpi/adapter/httpclient_spec.rb +0 -238
  25. data/spec/httpi/adapter/net_http_persistent_spec.rb +0 -46
  26. data/spec/httpi/adapter/net_http_spec.rb +0 -54
  27. data/spec/httpi/adapter/rack_spec.rb +0 -109
  28. data/spec/httpi/adapter_spec.rb +0 -68
  29. data/spec/httpi/auth/config_spec.rb +0 -163
  30. data/spec/httpi/auth/ssl_spec.rb +0 -216
  31. data/spec/httpi/cookie_spec.rb +0 -36
  32. data/spec/httpi/cookie_store_spec.rb +0 -26
  33. data/spec/httpi/error_spec.rb +0 -43
  34. data/spec/httpi/httpi_spec.rb +0 -382
  35. data/spec/httpi/request_spec.rb +0 -290
  36. data/spec/httpi/response_spec.rb +0 -146
  37. data/spec/integration/curb_spec.rb +0 -140
  38. data/spec/integration/em_http_spec.rb +0 -108
  39. data/spec/integration/excon_spec.rb +0 -174
  40. data/spec/integration/fixtures/ca_all.pem +0 -19
  41. data/spec/integration/fixtures/server.cert +0 -19
  42. data/spec/integration/fixtures/server.key +0 -27
  43. data/spec/integration/http_spec.rb +0 -156
  44. data/spec/integration/httpclient_spec.rb +0 -137
  45. data/spec/integration/net_http_persistent_spec.rb +0 -171
  46. data/spec/integration/net_http_spec.rb +0 -282
  47. data/spec/integration/support/application.rb +0 -88
  48. data/spec/integration/support/server.rb +0 -83
  49. data/spec/spec_helper.rb +0 -23
  50. data/spec/support/error_helper.rb +0 -26
  51. data/spec/support/fixture.rb +0 -27
  52. data/spec/support/matchers.rb +0 -19
@@ -1,174 +0,0 @@
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,19 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDDjC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FV
15
- ScPGznO/rNeKUsMFu3SXZNYs7aYqr9OCadwATuh+IzTQAx3T3prno4F5AoGBANIW
16
- kJRF2Pl4yWc7MRjF+WnGfhJHv7VOcLlmFD1fa/IIM9xuBRgikiBWHtFwLoXknsY8
17
- y2VqNrPEkjCp+qLpXLC8l3dzpNU33Z42h/tUfoTmgSgDUQXGggjzbcS8cf+1D55z
18
- KuPazKAndyiuhIENk1gE+5RKdNyjYP2sI4+L5jexAoGBANxx2rw9GywHj9n/P006
19
- pnO2Ol49nGsYiWp5E3bwZtIl+shf6GLgeRpWhj3TBnMhIlWnB/kpiiq8i0Tw7URo
20
- 9H+9IqRcNqTbX2ebeXjOCc+5DkLp4LQq83OmRsM1R+HTTtC4ipb9cucqpA1HOftp
21
- z5isGq3ctdXaxP8YsLuPcw1RAoGAXZx0W70ryy2JAJidbd55Hiq17ktOHumOzO2x
22
- Qw+Lt9Lz2NqlJnXxCruVC9miwUJ3hPl93/iN21hRk6GJ7qFxDcda7nz3C5LTCzZd
23
- LR4fKfTTxBKGPb6QHpDpbmpRmZECHqZOjCzoVMyBCf2JST/VUbkWqKLso4uhIidb
24
- yRCbSmECgYEAp+IuwpnMxVPxP52/xPFVcAxH2pDfmn5TJLJCNuKEUAS9ncZuz7rh
25
- jJxtbC4AoGsS0+TdxnlMBvBpZE3QddQmjvey77yu/OvRUX2m/J/d+I2duTaHGR9Z
26
- 9VMxtlFY+DbDkJI2HVVxu5XfLKMJSEsMza8K64Ntx3XY3dJLCHrR1EY=
27
- -----END RSA PRIVATE KEY-----
@@ -1,156 +0,0 @@
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
@@ -1,137 +0,0 @@
1
- require "spec_helper"
2
- require "integration/support/server"
3
-
4
- describe HTTPI::Adapter::HTTPClient do
5
-
6
- subject(:adapter) { :httpclient }
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 "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
-
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
- # Rack::Auth::Digest is removed in Rack 3.1
83
- xit "supports digest authentication" do
84
- request = HTTPI::Request.new(@server.url + "digest-auth")
85
- request.auth.digest("admin", "secret")
86
-
87
- response = HTTPI.get(request, adapter)
88
- expect(response.body).to eq("digest-auth")
89
- end
90
-
91
- it "supports chunked response" do
92
- request = HTTPI::Request.new(@server.url)
93
- res = ""
94
- request.on_body do |body|
95
- res += body
96
- end
97
- response = HTTPI.post(request, adapter)
98
- expect(res).to eq("post")
99
- expect(response.body).to eq("")
100
- end
101
- end
102
-
103
- if RUBY_PLATFORM =~ /java/
104
- pending "Puma Server complains: SSL not supported on JRuby"
105
- else
106
- context "https requests" do
107
- before :all do
108
- @server = IntegrationServer.run(:ssl => true)
109
- end
110
- after :all do
111
- @server.stop
112
- end
113
-
114
- it "raises when no certificate was set up" do
115
- expect { HTTPI.post(@server.url, "", adapter) }.to raise_error(HTTPI::SSLError)
116
- end
117
-
118
- it "works when set up properly" do
119
- request = HTTPI::Request.new(@server.url)
120
- request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
121
-
122
- response = HTTPI.get(request, adapter)
123
- expect(response.body).to eq("get")
124
- end
125
-
126
- it "works with ciphers" do
127
- request = HTTPI::Request.new(@server.url)
128
- request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
129
- request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
130
-
131
- response = HTTPI.get(request, adapter)
132
- expect(response.body).to eq("get")
133
- end
134
- end
135
- end
136
-
137
- end