faraday 1.0.0 → 2.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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +221 -1
  3. data/LICENSE.md +1 -1
  4. data/README.md +19 -14
  5. data/examples/client_spec.rb +36 -4
  6. data/examples/client_test.rb +43 -4
  7. data/lib/faraday/adapter/test.rb +61 -43
  8. data/lib/faraday/adapter.rb +3 -16
  9. data/lib/faraday/adapter_registry.rb +3 -1
  10. data/lib/faraday/connection.rb +25 -78
  11. data/lib/faraday/encoders/flat_params_encoder.rb +9 -2
  12. data/lib/faraday/encoders/nested_params_encoder.rb +9 -4
  13. data/lib/faraday/error.rb +23 -8
  14. data/lib/faraday/logging/formatter.rb +1 -0
  15. data/lib/faraday/methods.rb +6 -0
  16. data/lib/faraday/middleware.rb +14 -5
  17. data/lib/faraday/middleware_registry.rb +15 -79
  18. data/lib/faraday/options/proxy_options.rb +4 -0
  19. data/lib/faraday/options.rb +7 -11
  20. data/lib/faraday/rack_builder.rb +34 -30
  21. data/lib/faraday/request/authorization.rb +32 -36
  22. data/lib/faraday/request/instrumentation.rb +2 -0
  23. data/lib/faraday/request/json.rb +55 -0
  24. data/lib/faraday/request/url_encoded.rb +5 -1
  25. data/lib/faraday/request.rb +13 -23
  26. data/lib/faraday/response/json.rb +54 -0
  27. data/lib/faraday/response/logger.rb +4 -4
  28. data/lib/faraday/response/raise_error.rb +20 -1
  29. data/lib/faraday/response.rb +8 -22
  30. data/lib/faraday/utils/headers.rb +3 -3
  31. data/lib/faraday/utils.rb +21 -8
  32. data/lib/faraday/version.rb +5 -0
  33. data/lib/faraday.rb +44 -59
  34. data/spec/faraday/adapter/test_spec.rb +377 -0
  35. data/spec/faraday/connection_spec.rb +147 -51
  36. data/spec/faraday/error_spec.rb +15 -0
  37. data/spec/faraday/middleware_spec.rb +32 -6
  38. data/spec/faraday/options/env_spec.rb +2 -2
  39. data/spec/faraday/options/proxy_options_spec.rb +7 -0
  40. data/spec/faraday/params_encoders/flat_spec.rb +8 -0
  41. data/spec/faraday/params_encoders/nested_spec.rb +8 -0
  42. data/spec/faraday/rack_builder_spec.rb +144 -38
  43. data/spec/faraday/request/authorization_spec.rb +19 -24
  44. data/spec/faraday/request/instrumentation_spec.rb +5 -7
  45. data/spec/faraday/request/json_spec.rb +111 -0
  46. data/spec/faraday/request/url_encoded_spec.rb +13 -1
  47. data/spec/faraday/request_spec.rb +6 -6
  48. data/spec/faraday/response/json_spec.rb +117 -0
  49. data/spec/faraday/response/raise_error_spec.rb +66 -0
  50. data/spec/faraday/utils_spec.rb +62 -1
  51. data/spec/support/fake_safe_buffer.rb +1 -1
  52. data/spec/support/helper_methods.rb +0 -37
  53. data/spec/support/shared_examples/adapter.rb +2 -2
  54. data/spec/support/shared_examples/request_method.rb +43 -28
  55. metadata +16 -48
  56. data/UPGRADING.md +0 -55
  57. data/lib/faraday/adapter/em_http.rb +0 -285
  58. data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -62
  59. data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -69
  60. data/lib/faraday/adapter/em_synchrony.rb +0 -150
  61. data/lib/faraday/adapter/excon.rb +0 -124
  62. data/lib/faraday/adapter/httpclient.rb +0 -151
  63. data/lib/faraday/adapter/net_http.rb +0 -209
  64. data/lib/faraday/adapter/net_http_persistent.rb +0 -91
  65. data/lib/faraday/adapter/patron.rb +0 -132
  66. data/lib/faraday/adapter/rack.rb +0 -75
  67. data/lib/faraday/adapter/typhoeus.rb +0 -15
  68. data/lib/faraday/autoload.rb +0 -95
  69. data/lib/faraday/dependency_loader.rb +0 -37
  70. data/lib/faraday/file_part.rb +0 -128
  71. data/lib/faraday/param_part.rb +0 -53
  72. data/lib/faraday/request/basic_authentication.rb +0 -20
  73. data/lib/faraday/request/multipart.rb +0 -99
  74. data/lib/faraday/request/retry.rb +0 -239
  75. data/lib/faraday/request/token_authentication.rb +0 -20
  76. data/spec/faraday/adapter/em_http_spec.rb +0 -47
  77. data/spec/faraday/adapter/em_synchrony_spec.rb +0 -16
  78. data/spec/faraday/adapter/excon_spec.rb +0 -49
  79. data/spec/faraday/adapter/httpclient_spec.rb +0 -73
  80. data/spec/faraday/adapter/net_http_persistent_spec.rb +0 -57
  81. data/spec/faraday/adapter/net_http_spec.rb +0 -64
  82. data/spec/faraday/adapter/patron_spec.rb +0 -18
  83. data/spec/faraday/adapter/rack_spec.rb +0 -8
  84. data/spec/faraday/adapter/typhoeus_spec.rb +0 -7
  85. data/spec/faraday/composite_read_io_spec.rb +0 -80
  86. data/spec/faraday/request/multipart_spec.rb +0 -274
  87. data/spec/faraday/request/retry_spec.rb +0 -242
  88. data/spec/faraday/response/middleware_spec.rb +0 -52
  89. data/spec/support/webmock_rack_app.rb +0 -68
@@ -29,6 +29,9 @@ RSpec.describe Faraday::Response::RaiseError do
29
29
  expect(ex.message).to eq('the server responded with status 400')
30
30
  expect(ex.response[:headers]['X-Reason']).to eq('because')
31
31
  expect(ex.response[:status]).to eq(400)
32
+ expect(ex.response_status).to eq(400)
33
+ expect(ex.response_body).to eq('keep looking')
34
+ expect(ex.response_headers['X-Reason']).to eq('because')
32
35
  end
33
36
  end
34
37
 
@@ -37,6 +40,9 @@ RSpec.describe Faraday::Response::RaiseError do
37
40
  expect(ex.message).to eq('the server responded with status 401')
38
41
  expect(ex.response[:headers]['X-Reason']).to eq('because')
39
42
  expect(ex.response[:status]).to eq(401)
43
+ expect(ex.response_status).to eq(401)
44
+ expect(ex.response_body).to eq('keep looking')
45
+ expect(ex.response_headers['X-Reason']).to eq('because')
40
46
  end
41
47
  end
42
48
 
@@ -45,6 +51,9 @@ RSpec.describe Faraday::Response::RaiseError do
45
51
  expect(ex.message).to eq('the server responded with status 403')
46
52
  expect(ex.response[:headers]['X-Reason']).to eq('because')
47
53
  expect(ex.response[:status]).to eq(403)
54
+ expect(ex.response_status).to eq(403)
55
+ expect(ex.response_body).to eq('keep looking')
56
+ expect(ex.response_headers['X-Reason']).to eq('because')
48
57
  end
49
58
  end
50
59
 
@@ -53,6 +62,9 @@ RSpec.describe Faraday::Response::RaiseError do
53
62
  expect(ex.message).to eq('the server responded with status 404')
54
63
  expect(ex.response[:headers]['X-Reason']).to eq('because')
55
64
  expect(ex.response[:status]).to eq(404)
65
+ expect(ex.response_status).to eq(404)
66
+ expect(ex.response_body).to eq('keep looking')
67
+ expect(ex.response_headers['X-Reason']).to eq('because')
56
68
  end
57
69
  end
58
70
 
@@ -61,6 +73,9 @@ RSpec.describe Faraday::Response::RaiseError do
61
73
  expect(ex.message).to eq('407 "Proxy Authentication Required"')
62
74
  expect(ex.response[:headers]['X-Reason']).to eq('because')
63
75
  expect(ex.response[:status]).to eq(407)
76
+ expect(ex.response_status).to eq(407)
77
+ expect(ex.response_body).to eq('keep looking')
78
+ expect(ex.response_headers['X-Reason']).to eq('because')
64
79
  end
65
80
  end
66
81
 
@@ -69,6 +84,9 @@ RSpec.describe Faraday::Response::RaiseError do
69
84
  expect(ex.message).to eq('the server responded with status 409')
70
85
  expect(ex.response[:headers]['X-Reason']).to eq('because')
71
86
  expect(ex.response[:status]).to eq(409)
87
+ expect(ex.response_status).to eq(409)
88
+ expect(ex.response_body).to eq('keep looking')
89
+ expect(ex.response_headers['X-Reason']).to eq('because')
72
90
  end
73
91
  end
74
92
 
@@ -77,6 +95,9 @@ RSpec.describe Faraday::Response::RaiseError do
77
95
  expect(ex.message).to eq('the server responded with status 422')
78
96
  expect(ex.response[:headers]['X-Reason']).to eq('because')
79
97
  expect(ex.response[:status]).to eq(422)
98
+ expect(ex.response_status).to eq(422)
99
+ expect(ex.response_body).to eq('keep looking')
100
+ expect(ex.response_headers['X-Reason']).to eq('because')
80
101
  end
81
102
  end
82
103
 
@@ -85,6 +106,9 @@ RSpec.describe Faraday::Response::RaiseError do
85
106
  expect(ex.message).to eq('http status could not be derived from the server response')
86
107
  expect(ex.response[:headers]['X-Reason']).to eq('nil')
87
108
  expect(ex.response[:status]).to be_nil
109
+ expect(ex.response_status).to be_nil
110
+ expect(ex.response_body).to eq('fail')
111
+ expect(ex.response_headers['X-Reason']).to eq('nil')
88
112
  end
89
113
  end
90
114
 
@@ -93,6 +117,9 @@ RSpec.describe Faraday::Response::RaiseError do
93
117
  expect(ex.message).to eq('the server responded with status 499')
94
118
  expect(ex.response[:headers]['X-Reason']).to eq('because')
95
119
  expect(ex.response[:status]).to eq(499)
120
+ expect(ex.response_status).to eq(499)
121
+ expect(ex.response_body).to eq('keep looking')
122
+ expect(ex.response_headers['X-Reason']).to eq('because')
96
123
  end
97
124
  end
98
125
 
@@ -101,6 +128,45 @@ RSpec.describe Faraday::Response::RaiseError do
101
128
  expect(ex.message).to eq('the server responded with status 500')
102
129
  expect(ex.response[:headers]['X-Error']).to eq('bailout')
103
130
  expect(ex.response[:status]).to eq(500)
131
+ expect(ex.response_status).to eq(500)
132
+ expect(ex.response_body).to eq('fail')
133
+ expect(ex.response_headers['X-Error']).to eq('bailout')
134
+ end
135
+ end
136
+
137
+ describe 'request info' do
138
+ let(:conn) do
139
+ Faraday.new do |b|
140
+ b.response :raise_error
141
+ b.adapter :test do |stub|
142
+ stub.post(url, request_body, request_headers) do
143
+ [400, { 'X-Reason' => 'because' }, 'keep looking']
144
+ end
145
+ end
146
+ end
147
+ end
148
+ let(:request_body) { JSON.generate({ 'item' => 'sth' }) }
149
+ let(:request_headers) { { 'Authorization' => 'Basic 123' } }
150
+ let(:url_path) { 'request' }
151
+ let(:query_params) { 'full=true' }
152
+ let(:url) { "#{url_path}?#{query_params}" }
153
+
154
+ subject(:perform_request) do
155
+ conn.post url do |req|
156
+ req.headers['Authorization'] = 'Basic 123'
157
+ req.body = request_body
158
+ end
159
+ end
160
+
161
+ it 'returns the request info in the exception' do
162
+ expect { perform_request }.to raise_error(Faraday::BadRequestError) do |ex|
163
+ expect(ex.response[:request][:method]).to eq(:post)
164
+ expect(ex.response[:request][:url]).to eq(URI("http:/#{url}"))
165
+ expect(ex.response[:request][:url_path]).to eq("/#{url_path}")
166
+ expect(ex.response[:request][:params]).to eq({ 'full' => 'true' })
167
+ expect(ex.response[:request][:headers]).to match(a_hash_including(request_headers))
168
+ expect(ex.response[:request][:body]).to eq(request_body)
169
+ end
104
170
  end
105
171
  end
106
172
  end
@@ -4,7 +4,7 @@ RSpec.describe Faraday::Utils do
4
4
  describe 'headers parsing' do
5
5
  let(:multi_response_headers) do
6
6
  "HTTP/1.x 500 OK\r\nContent-Type: text/html; charset=UTF-8\r\n" \
7
- "HTTP/1.x 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n"
7
+ "HTTP/1.x 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n"
8
8
  end
9
9
 
10
10
  it 'parse headers for aggregated responses' do
@@ -53,4 +53,65 @@ RSpec.describe Faraday::Utils do
53
53
  expect(headers).not_to have_key('authorization')
54
54
  end
55
55
  end
56
+
57
+ describe '.deep_merge!' do
58
+ let(:connection_options) { Faraday::ConnectionOptions.new }
59
+ let(:url) do
60
+ {
61
+ url: 'http://example.com/abc',
62
+ headers: { 'Mime-Version' => '1.0' },
63
+ request: { oauth: { consumer_key: 'anonymous' } },
64
+ ssl: { version: '2' }
65
+ }
66
+ end
67
+
68
+ it 'recursively merges the headers' do
69
+ connection_options.headers = { user_agent: 'My Agent 1.0' }
70
+ deep_merge = Faraday::Utils.deep_merge!(connection_options, url)
71
+
72
+ expect(deep_merge.headers).to eq('Mime-Version' => '1.0', user_agent: 'My Agent 1.0')
73
+ end
74
+
75
+ context 'when a target hash has an Options Struct value' do
76
+ let(:request) do
77
+ {
78
+ params_encoder: nil,
79
+ proxy: nil,
80
+ bind: nil,
81
+ timeout: nil,
82
+ open_timeout: nil,
83
+ read_timeout: nil,
84
+ write_timeout: nil,
85
+ boundary: nil,
86
+ oauth: { consumer_key: 'anonymous' },
87
+ context: nil,
88
+ on_data: nil
89
+ }
90
+ end
91
+ let(:ssl) do
92
+ {
93
+ verify: nil,
94
+ ca_file: nil,
95
+ ca_path: nil,
96
+ verify_mode: nil,
97
+ cert_store: nil,
98
+ client_cert: nil,
99
+ client_key: nil,
100
+ certificate: nil,
101
+ private_key: nil,
102
+ verify_depth: nil,
103
+ version: '2',
104
+ min_version: nil,
105
+ max_version: nil
106
+ }
107
+ end
108
+
109
+ it 'does not overwrite an Options Struct value' do
110
+ deep_merge = Faraday::Utils.deep_merge!(connection_options, url)
111
+
112
+ expect(deep_merge.request.to_h).to eq(request)
113
+ expect(deep_merge.ssl.to_h).to eq(ssl)
114
+ end
115
+ end
116
+ end
56
117
  end
@@ -8,7 +8,7 @@ FakeSafeBuffer = Struct.new(:string) do
8
8
 
9
9
  def gsub(regex)
10
10
  string.gsub(regex) do
11
- match, = $&, '' =~ /a/
11
+ match, = Regexp.last_match(0), '' =~ /a/ # rubocop:disable Performance/StringInclude
12
12
  yield(match)
13
13
  end
14
14
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'multipart_parser/reader'
4
-
5
3
  module Faraday
6
4
  module HelperMethods
7
5
  def self.included(base)
@@ -86,41 +84,6 @@ module Faraday
86
84
  end
87
85
  end
88
86
 
89
- def multipart_file
90
- Faraday::FilePart.new(__FILE__, 'text/x-ruby')
91
- end
92
-
93
- # parse boundary out of a Content-Type header like:
94
- # Content-Type: multipart/form-data; boundary=gc0p4Jq0M2Yt08jU534c0p
95
- def parse_multipart_boundary(ctype)
96
- MultipartParser::Reader.extract_boundary_value(ctype)
97
- end
98
-
99
- # parse a multipart MIME message, returning a hash of any multipart errors
100
- def parse_multipart(boundary, body)
101
- reader = MultipartParser::Reader.new(boundary)
102
- result = { errors: [], parts: [] }
103
- def result.part(name)
104
- hash = self[:parts].detect { |h| h[:part].name == name }
105
- [hash[:part], hash[:body].join]
106
- end
107
-
108
- reader.on_part do |part|
109
- result[:parts] << thispart = {
110
- part: part,
111
- body: []
112
- }
113
- part.on_data do |chunk|
114
- thispart[:body] << chunk
115
- end
116
- end
117
- reader.on_error do |msg|
118
- result[:errors] << msg
119
- end
120
- reader.write(body)
121
- result
122
- end
123
-
124
87
  def method_with_body?(method)
125
88
  self.class.method_with_body?(method)
126
89
  end
@@ -33,20 +33,20 @@ shared_examples 'adapter examples' do |**options|
33
33
 
34
34
  let(:protocol) { ssl_mode? ? 'https' : 'http' }
35
35
  let(:remote) { "#{protocol}://example.com" }
36
+ let(:stub_remote) { remote }
36
37
 
37
38
  let(:conn) do
38
39
  conn_options[:ssl] ||= {}
39
40
  conn_options[:ssl][:ca_file] ||= ENV['SSL_FILE']
40
41
 
41
42
  Faraday.new(remote, conn_options) do |conn|
42
- conn.request :multipart
43
43
  conn.request :url_encoded
44
44
  conn.response :raise_error
45
45
  conn.adapter described_class, *adapter_options
46
46
  end
47
47
  end
48
48
 
49
- let!(:request_stub) { stub_request(http_method, remote) }
49
+ let!(:request_stub) { stub_request(http_method, stub_remote) }
50
50
 
51
51
  after do
52
52
  expect(request_stub).to have_been_requested unless request_stub.disabled?
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ shared_examples 'proxy examples' do
4
+ it 'handles requests with proxy' do
5
+ res = conn.public_send(http_method, '/')
6
+
7
+ expect(res.status).to eq(200)
8
+ end
9
+
10
+ it 'handles proxy failures' do
11
+ request_stub.to_return(status: 407)
12
+
13
+ expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
14
+ end
15
+ end
16
+
3
17
  shared_examples 'a request method' do |http_method|
4
18
  let(:query_or_body) { method_with_body?(http_method) ? :body : :query }
5
19
  let(:response) { conn.public_send(http_method, '/') }
@@ -13,8 +27,8 @@ shared_examples 'a request method' do |http_method|
13
27
  end
14
28
 
15
29
  it 'handles headers with multiple values' do
16
- request_stub.to_return(headers: { 'Set-Cookie' => 'one, two' })
17
- expect(response.headers['set-cookie']).to eq('one, two')
30
+ request_stub.to_return(headers: { 'Set-Cookie' => 'name=value' })
31
+ expect(response.headers['set-cookie']).to eq('name=value')
18
32
  end
19
33
 
20
34
  it 'retrieves the response headers' do
@@ -65,7 +79,7 @@ shared_examples 'a request method' do |http_method|
65
79
 
66
80
  on_feature :request_body_on_query_methods do
67
81
  it 'sends request body' do
68
- request_stub.with(Hash[:body, 'test'])
82
+ request_stub.with({ body: 'test' })
69
83
  res = if query_or_body == :body
70
84
  conn.public_send(http_method, '/', 'test')
71
85
  else
@@ -79,7 +93,7 @@ shared_examples 'a request method' do |http_method|
79
93
 
80
94
  it 'sends url encoded parameters' do
81
95
  payload = { name: 'zack' }
82
- request_stub.with(Hash[query_or_body, payload])
96
+ request_stub.with({ query_or_body => payload })
83
97
  res = conn.public_send(http_method, '/', payload)
84
98
  if query_or_body == :query
85
99
  expect(res.env.request_body).to be_nil
@@ -90,7 +104,7 @@ shared_examples 'a request method' do |http_method|
90
104
 
91
105
  it 'sends url encoded nested parameters' do
92
106
  payload = { name: { first: 'zack' } }
93
- request_stub.with(Hash[query_or_body, payload])
107
+ request_stub.with({ query_or_body => payload })
94
108
  conn.public_send(http_method, '/', payload)
95
109
  end
96
110
 
@@ -112,19 +126,6 @@ shared_examples 'a request method' do |http_method|
112
126
  expect { conn.public_send(http_method, '/') }.to raise_error(exc)
113
127
  end
114
128
 
115
- # Can't send files on get, head and delete methods
116
- if method_with_body?(http_method)
117
- it 'sends files' do
118
- payload = { uploaded_file: multipart_file }
119
- request_stub.with(headers: { 'Content-Type' => %r{\Amultipart/form-data} }) do |request|
120
- # WebMock does not support matching body for multipart/form-data requests yet :(
121
- # https://github.com/bblimke/webmock/issues/623
122
- request.body =~ /RubyMultipartPost/
123
- end
124
- conn.public_send(http_method, '/', payload)
125
- end
126
- end
127
-
128
129
  on_feature :reason_phrase_parse do
129
130
  it 'parses the reason phrase' do
130
131
  request_stub.to_return(status: [200, 'OK'])
@@ -185,11 +186,11 @@ shared_examples 'a request method' do |http_method|
185
186
  @payload2 = { b: '2' }
186
187
 
187
188
  request_stub
188
- .with(Hash[query_or_body, @payload1])
189
+ .with({ query_or_body => @payload1 })
189
190
  .to_return(body: @payload1.to_json)
190
191
 
191
192
  stub_request(http_method, remote)
192
- .with(Hash[query_or_body, @payload2])
193
+ .with({ query_or_body => @payload2 })
193
194
  .to_return(body: @payload2.to_json)
194
195
 
195
196
  conn.in_parallel do
@@ -218,17 +219,31 @@ shared_examples 'a request method' do |http_method|
218
219
  end
219
220
  end
220
221
 
221
- it 'handles requests with proxy' do
222
- conn_options[:proxy] = 'http://google.co.uk'
222
+ context 'when a proxy is provided as option' do
223
+ before do
224
+ conn_options[:proxy] = 'http://env-proxy.com:80'
225
+ end
223
226
 
224
- res = conn.public_send(http_method, '/')
225
- expect(res.status).to eq(200)
227
+ include_examples 'proxy examples'
226
228
  end
227
229
 
228
- it 'handles proxy failures' do
229
- conn_options[:proxy] = 'http://google.co.uk'
230
- request_stub.to_return(status: 407)
230
+ context 'when http_proxy env variable is set' do
231
+ let(:proxy_url) { 'http://env-proxy.com:80' }
231
232
 
232
- expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
233
+ around do |example|
234
+ with_env 'http_proxy' => proxy_url do
235
+ example.run
236
+ end
237
+ end
238
+
239
+ include_examples 'proxy examples'
240
+
241
+ context 'when the env proxy is ignored' do
242
+ around do |example|
243
+ with_env_proxy_disabled(&example)
244
+ end
245
+
246
+ include_examples 'proxy examples'
247
+ end
233
248
  end
234
249
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
@@ -10,28 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-01-01 00:00:00.000000000 Z
13
+ date: 2022-01-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: multipart-post
16
+ name: ruby2_keywords
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.2'
22
- - - "<"
23
- - !ruby/object:Gem::Version
24
- version: '3'
21
+ version: 0.0.4
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
26
  - - ">="
30
27
  - !ruby/object:Gem::Version
31
- version: '1.2'
32
- - - "<"
33
- - !ruby/object:Gem::Version
34
- version: '3'
28
+ version: 0.0.4
35
29
  description:
36
30
  email: technoweenie@gmail.com
37
31
  executables: []
@@ -42,32 +36,18 @@ files:
42
36
  - LICENSE.md
43
37
  - README.md
44
38
  - Rakefile
45
- - UPGRADING.md
46
39
  - examples/client_spec.rb
47
40
  - examples/client_test.rb
48
41
  - lib/faraday.rb
49
42
  - lib/faraday/adapter.rb
50
- - lib/faraday/adapter/em_http.rb
51
- - lib/faraday/adapter/em_http_ssl_patch.rb
52
- - lib/faraday/adapter/em_synchrony.rb
53
- - lib/faraday/adapter/em_synchrony/parallel_manager.rb
54
- - lib/faraday/adapter/excon.rb
55
- - lib/faraday/adapter/httpclient.rb
56
- - lib/faraday/adapter/net_http.rb
57
- - lib/faraday/adapter/net_http_persistent.rb
58
- - lib/faraday/adapter/patron.rb
59
- - lib/faraday/adapter/rack.rb
60
43
  - lib/faraday/adapter/test.rb
61
- - lib/faraday/adapter/typhoeus.rb
62
44
  - lib/faraday/adapter_registry.rb
63
- - lib/faraday/autoload.rb
64
45
  - lib/faraday/connection.rb
65
- - lib/faraday/dependency_loader.rb
66
46
  - lib/faraday/encoders/flat_params_encoder.rb
67
47
  - lib/faraday/encoders/nested_params_encoder.rb
68
48
  - lib/faraday/error.rb
69
- - lib/faraday/file_part.rb
70
49
  - lib/faraday/logging/formatter.rb
50
+ - lib/faraday/methods.rb
71
51
  - lib/faraday/middleware.rb
72
52
  - lib/faraday/middleware_registry.rb
73
53
  - lib/faraday/options.rb
@@ -76,36 +56,25 @@ files:
76
56
  - lib/faraday/options/proxy_options.rb
77
57
  - lib/faraday/options/request_options.rb
78
58
  - lib/faraday/options/ssl_options.rb
79
- - lib/faraday/param_part.rb
80
59
  - lib/faraday/parameters.rb
81
60
  - lib/faraday/rack_builder.rb
82
61
  - lib/faraday/request.rb
83
62
  - lib/faraday/request/authorization.rb
84
- - lib/faraday/request/basic_authentication.rb
85
63
  - lib/faraday/request/instrumentation.rb
86
- - lib/faraday/request/multipart.rb
87
- - lib/faraday/request/retry.rb
88
- - lib/faraday/request/token_authentication.rb
64
+ - lib/faraday/request/json.rb
89
65
  - lib/faraday/request/url_encoded.rb
90
66
  - lib/faraday/response.rb
67
+ - lib/faraday/response/json.rb
91
68
  - lib/faraday/response/logger.rb
92
69
  - lib/faraday/response/raise_error.rb
93
70
  - lib/faraday/utils.rb
94
71
  - lib/faraday/utils/headers.rb
95
72
  - lib/faraday/utils/params_hash.rb
73
+ - lib/faraday/version.rb
96
74
  - spec/external_adapters/faraday_specs_setup.rb
97
- - spec/faraday/adapter/em_http_spec.rb
98
- - spec/faraday/adapter/em_synchrony_spec.rb
99
- - spec/faraday/adapter/excon_spec.rb
100
- - spec/faraday/adapter/httpclient_spec.rb
101
- - spec/faraday/adapter/net_http_persistent_spec.rb
102
- - spec/faraday/adapter/net_http_spec.rb
103
- - spec/faraday/adapter/patron_spec.rb
104
- - spec/faraday/adapter/rack_spec.rb
105
- - spec/faraday/adapter/typhoeus_spec.rb
75
+ - spec/faraday/adapter/test_spec.rb
106
76
  - spec/faraday/adapter_registry_spec.rb
107
77
  - spec/faraday/adapter_spec.rb
108
- - spec/faraday/composite_read_io_spec.rb
109
78
  - spec/faraday/connection_spec.rb
110
79
  - spec/faraday/error_spec.rb
111
80
  - spec/faraday/middleware_spec.rb
@@ -118,12 +87,11 @@ files:
118
87
  - spec/faraday/rack_builder_spec.rb
119
88
  - spec/faraday/request/authorization_spec.rb
120
89
  - spec/faraday/request/instrumentation_spec.rb
121
- - spec/faraday/request/multipart_spec.rb
122
- - spec/faraday/request/retry_spec.rb
90
+ - spec/faraday/request/json_spec.rb
123
91
  - spec/faraday/request/url_encoded_spec.rb
124
92
  - spec/faraday/request_spec.rb
93
+ - spec/faraday/response/json_spec.rb
125
94
  - spec/faraday/response/logger_spec.rb
126
- - spec/faraday/response/middleware_spec.rb
127
95
  - spec/faraday/response/raise_error_spec.rb
128
96
  - spec/faraday/response_spec.rb
129
97
  - spec/faraday/utils/headers_spec.rb
@@ -137,31 +105,31 @@ files:
137
105
  - spec/support/shared_examples/params_encoder.rb
138
106
  - spec/support/shared_examples/request_method.rb
139
107
  - spec/support/streaming_response_checker.rb
140
- - spec/support/webmock_rack_app.rb
141
108
  homepage: https://lostisland.github.io/faraday
142
109
  licenses:
143
110
  - MIT
144
111
  metadata:
145
112
  homepage_uri: https://lostisland.github.io/faraday
146
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.0.0
113
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.0.0
147
114
  source_code_uri: https://github.com/lostisland/faraday
148
115
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
149
116
  post_install_message:
150
117
  rdoc_options: []
151
118
  require_paths:
152
119
  - lib
120
+ - spec/external_adapters
153
121
  required_ruby_version: !ruby/object:Gem::Requirement
154
122
  requirements:
155
123
  - - ">="
156
124
  - !ruby/object:Gem::Version
157
- version: '2.3'
125
+ version: '2.6'
158
126
  required_rubygems_version: !ruby/object:Gem::Requirement
159
127
  requirements:
160
128
  - - ">="
161
129
  - !ruby/object:Gem::Version
162
130
  version: '0'
163
131
  requirements: []
164
- rubygems_version: 3.1.2
132
+ rubygems_version: 3.1.6
165
133
  signing_key:
166
134
  specification_version: 4
167
135
  summary: HTTP/REST API client library.
data/UPGRADING.md DELETED
@@ -1,55 +0,0 @@
1
- ## Faraday 1.0
2
-
3
- ### Errors
4
- * Removes sub-class constants definition from `Faraday::Error`. A sub-class (e.g. `ClientError`) was previously accessible
5
- either through the `Faraday` module (e.g. `Faraday::ClientError`) or through the `Faraday::Error` class (e.g. `Faraday::Error::ClientError`).
6
- The latter is no longer available and the former should be used instead, so check your `rescue`s.
7
- * Introduces a new `Faraday::ServerError` (5xx status codes) alongside the existing `Faraday::ClientError` (4xx status codes).
8
- Please note `Faraday::ClientError` was previously used for both.
9
- * Introduces new Errors that describe the most common REST status codes:
10
- * Faraday::BadRequestError (400)
11
- * Faraday::UnauthorizedError (401)
12
- * Faraday::ForbiddenError (403)
13
- * Faraday::ProxyAuthError (407). Please note this raised a `Faraday::ConnectionFailed` before.
14
- * Faraday::ConflictError (409)
15
- * Faraday::UnprocessableEntityError (422)
16
- * The following error classes have changed the hierarchy to better mirror their real-world usage and semantic meaning:
17
- * TimeoutError < ServerError (was < ClientError)
18
- * ConnectionFailed < Error (was < ClientError)
19
- * SSLError < Error (was < ClientError)
20
- * ParsingError < Error (was < ClientError)
21
- * RetriableResponse < Error (was < ClientError)
22
-
23
- ### Custom adapters
24
- If you have written a custom adapter, please be aware that `env.body` is now an alias to the two new properties `request_body` and `response_body`.
25
- This should work without you noticing if your adapter inherits from `Faraday::Adapter` and calls `save_response`, but if it doesn't, then please ensure you set the `status` BEFORE the `body` while processing the response.
26
-
27
- ### Others
28
- * Dropped support for jruby and Rubinius.
29
- * Officially supports Ruby 2.4+
30
- * In order to specify the adapter you now MUST use the `#adapter` method on the connection builder. If you don't do so and your adapter inherits from `Faraday::Adapter` then Faraday will raise an exception. Otherwise, Faraday will automatically push the default adapter at the end of the stack causing your request to be executed twice.
31
- ```ruby
32
- class OfficialAdapter < Faraday::Adapter
33
- ...
34
- end
35
-
36
- class MyAdapter
37
- ...
38
- end
39
-
40
- # This will raise an exception
41
- conn = Faraday.new(...) do |f|
42
- f.use OfficialAdapter
43
- end
44
-
45
- # This will cause Faraday inserting the default adapter at the end of the stack
46
- conn = Faraday.new(...) do |f|
47
- f.use MyAdapter
48
- end
49
-
50
- # You MUST use `adapter` method
51
- conn = Faraday.new(...) do |f|
52
- f.adapter AnyAdapter
53
- end
54
- ```
55
-