faraday 0.11.0 → 1.4.3
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/CHANGELOG.md +380 -0
- data/LICENSE.md +1 -1
- data/README.md +25 -229
- data/Rakefile +7 -0
- data/examples/client_spec.rb +65 -0
- data/examples/client_test.rb +79 -0
- data/lib/faraday/adapter/httpclient.rb +83 -59
- data/lib/faraday/adapter/patron.rb +92 -36
- data/lib/faraday/adapter/rack.rb +30 -13
- data/lib/faraday/adapter/test.rb +103 -62
- data/lib/faraday/adapter/typhoeus.rb +7 -115
- data/lib/faraday/adapter.rb +77 -22
- data/lib/faraday/adapter_registry.rb +30 -0
- data/lib/faraday/autoload.rb +42 -36
- data/lib/faraday/connection.rb +351 -167
- data/lib/faraday/dependency_loader.rb +37 -0
- data/lib/faraday/encoders/flat_params_encoder.rb +105 -0
- data/lib/faraday/encoders/nested_params_encoder.rb +176 -0
- data/lib/faraday/error.rb +127 -38
- data/lib/faraday/file_part.rb +128 -0
- data/lib/faraday/logging/formatter.rb +105 -0
- data/lib/faraday/methods.rb +6 -0
- data/lib/faraday/middleware.rb +19 -25
- data/lib/faraday/middleware_registry.rb +129 -0
- data/lib/faraday/options/connection_options.rb +22 -0
- data/lib/faraday/options/env.rb +181 -0
- data/lib/faraday/options/proxy_options.rb +32 -0
- data/lib/faraday/options/request_options.rb +22 -0
- data/lib/faraday/options/ssl_options.rb +59 -0
- data/lib/faraday/options.rb +58 -207
- data/lib/faraday/param_part.rb +53 -0
- data/lib/faraday/parameters.rb +4 -196
- data/lib/faraday/rack_builder.rb +84 -48
- data/lib/faraday/request/authorization.rb +44 -30
- data/lib/faraday/request/basic_authentication.rb +14 -7
- data/lib/faraday/request/instrumentation.rb +45 -27
- data/lib/faraday/request/multipart.rb +88 -45
- data/lib/faraday/request/retry.rb +211 -126
- data/lib/faraday/request/token_authentication.rb +15 -10
- data/lib/faraday/request/url_encoded.rb +43 -23
- data/lib/faraday/request.rb +94 -32
- data/lib/faraday/response/logger.rb +22 -69
- data/lib/faraday/response/raise_error.rb +49 -14
- data/lib/faraday/response.rb +27 -23
- data/lib/faraday/utils/headers.rb +139 -0
- data/lib/faraday/utils/params_hash.rb +61 -0
- data/lib/faraday/utils.rb +38 -238
- data/lib/faraday/version.rb +5 -0
- data/lib/faraday.rb +124 -187
- data/spec/external_adapters/faraday_specs_setup.rb +14 -0
- data/spec/faraday/adapter/em_http_spec.rb +47 -0
- data/spec/faraday/adapter/em_synchrony_spec.rb +16 -0
- data/spec/faraday/adapter/excon_spec.rb +49 -0
- data/spec/faraday/adapter/httpclient_spec.rb +73 -0
- data/spec/faraday/adapter/net_http_spec.rb +64 -0
- data/spec/faraday/adapter/patron_spec.rb +18 -0
- data/spec/faraday/adapter/rack_spec.rb +8 -0
- data/spec/faraday/adapter/test_spec.rb +260 -0
- data/spec/faraday/adapter/typhoeus_spec.rb +7 -0
- data/spec/faraday/adapter_registry_spec.rb +28 -0
- data/spec/faraday/adapter_spec.rb +55 -0
- data/spec/faraday/composite_read_io_spec.rb +80 -0
- data/spec/faraday/connection_spec.rb +736 -0
- data/spec/faraday/error_spec.rb +60 -0
- data/spec/faraday/middleware_spec.rb +52 -0
- data/spec/faraday/options/env_spec.rb +70 -0
- data/spec/faraday/options/options_spec.rb +297 -0
- data/spec/faraday/options/proxy_options_spec.rb +44 -0
- data/spec/faraday/options/request_options_spec.rb +19 -0
- data/spec/faraday/params_encoders/flat_spec.rb +42 -0
- data/spec/faraday/params_encoders/nested_spec.rb +142 -0
- data/spec/faraday/rack_builder_spec.rb +345 -0
- data/spec/faraday/request/authorization_spec.rb +88 -0
- data/spec/faraday/request/instrumentation_spec.rb +76 -0
- data/spec/faraday/request/multipart_spec.rb +302 -0
- data/spec/faraday/request/retry_spec.rb +242 -0
- data/spec/faraday/request/url_encoded_spec.rb +83 -0
- data/spec/faraday/request_spec.rb +120 -0
- data/spec/faraday/response/logger_spec.rb +220 -0
- data/spec/faraday/response/middleware_spec.rb +68 -0
- data/spec/faraday/response/raise_error_spec.rb +169 -0
- data/spec/faraday/response_spec.rb +75 -0
- data/spec/faraday/utils/headers_spec.rb +82 -0
- data/spec/faraday/utils_spec.rb +56 -0
- data/spec/faraday_spec.rb +37 -0
- data/spec/spec_helper.rb +132 -0
- data/spec/support/disabling_stub.rb +14 -0
- data/spec/support/fake_safe_buffer.rb +15 -0
- data/spec/support/helper_methods.rb +133 -0
- data/spec/support/shared_examples/adapter.rb +105 -0
- data/spec/support/shared_examples/params_encoder.rb +18 -0
- data/spec/support/shared_examples/request_method.rb +262 -0
- data/spec/support/streaming_response_checker.rb +35 -0
- data/spec/support/webmock_rack_app.rb +68 -0
- metadata +164 -16
- data/lib/faraday/adapter/em_http.rb +0 -243
- data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -56
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -66
- data/lib/faraday/adapter/em_synchrony.rb +0 -106
- data/lib/faraday/adapter/excon.rb +0 -80
- data/lib/faraday/adapter/net_http.rb +0 -135
- data/lib/faraday/adapter/net_http_persistent.rb +0 -50
- data/lib/faraday/upload_io.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc82ee913ef4ffa6468eea5e656c49d4eab0f769321eb63a85fdb4caa9a90143
|
4
|
+
data.tar.gz: cccf1ae40f10f353ca2cc5e4e92bb01e4b1d65a9ac3ed50b7e5c5951680ba019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5360375fef63ad3e1068792458dd8ccc956b603be65e5571b9b6ce73938fc7ba2d220aeb99d4f3b022fa9945a07c8264c6452916e58963883fdd6843ded2d58e
|
7
|
+
data.tar.gz: fac76254509856e7e827fecda3c76a070c53cdb1771782ff5d668f14a4b8a4b126be9761d0856fe28eccda4607daf031cb7c8ea4559e245b100db08e95f01a0a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,380 @@
|
|
1
|
+
# Faraday Changelog
|
2
|
+
|
3
|
+
## [v1.3.0](https://github.com/lostisland/faraday/releases/tag/v1.3.0) (2020-12-31)
|
4
|
+
|
5
|
+
### Highlights
|
6
|
+
Faraday v1.3.0 is the first release to officially support Ruby 3.0 in the CI pipeline 🎉 🍾!
|
7
|
+
|
8
|
+
This is also the first release with a previously "included" adapter (Net::HTTP) being isolated into a [separate gem](https://github.com/lostisland/faraday-net_http) 🎊!
|
9
|
+
The new adapter is added to Faraday as a dependency for now, so that means full backwards-compatibility, but just to be safe be careful when upgrading!
|
10
|
+
|
11
|
+
This is a huge step towards are Faraday v2.0 objective of pushing adapters and middleware into separate gems.
|
12
|
+
Many thanks to the Faraday Team, @JanDintel and everyone who attended the [ROSS Conf remote event](https://www.rossconf.io/event/remote/)
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* Improves consistency with Faraday::Error and Faraday::RaiseError (#1229, @qsona, @iMacTia)
|
17
|
+
|
18
|
+
### Fixes
|
19
|
+
|
20
|
+
* Don't assign to global ::Timer (#1227, @bpo)
|
21
|
+
|
22
|
+
### Documentation
|
23
|
+
|
24
|
+
* CHANGELOG: add releases after 1.0 (#1225, @olleolleolle)
|
25
|
+
* Improves retry middleware documentation. (#1228, @iMacTia)
|
26
|
+
|
27
|
+
### Misc
|
28
|
+
|
29
|
+
* Move out Net::HTTP adapter (#1222, @JanDintel, @iMacTia)
|
30
|
+
* Adds Ruby 3.0 to CI Matrix (#1226, @iMacTia)
|
31
|
+
|
32
|
+
|
33
|
+
## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
|
34
|
+
|
35
|
+
### Features
|
36
|
+
|
37
|
+
* Introduces `on_request` and `on_complete` methods in `Faraday::Middleware`. (#1194, @iMacTia)
|
38
|
+
|
39
|
+
### Fixes
|
40
|
+
|
41
|
+
* Require 'date' to avoid retry exception (#1206, @rustygeldmacher)
|
42
|
+
* Fix rdebug recursion issue (#1205, @native-api)
|
43
|
+
* Update call to `em_http_ssl_patch` (#1202, @kylekeesling)
|
44
|
+
* `EmHttp` adapter: drop superfluous loaded? check (#1213, @olleolleolle)
|
45
|
+
* Avoid 1 use of keyword hackery (#1211, @grosser)
|
46
|
+
* Fix #1219 `Net::HTTP` still uses env proxy (#1221, @iMacTia)
|
47
|
+
|
48
|
+
### Documentation
|
49
|
+
|
50
|
+
* Add comment in gemspec to explain exposure of `examples` and `spec` folders. (#1192, @iMacTia)
|
51
|
+
* Adapters, how to create them (#1193, @olleolleolle)
|
52
|
+
* Update documentation on using the logger (#1196, @tijmenb)
|
53
|
+
* Adjust the retry documentation and spec to align with implementation (#1198, @nbeyer)
|
54
|
+
|
55
|
+
### Misc
|
56
|
+
|
57
|
+
* Test against ruby head (#1208, @grosser)
|
58
|
+
|
59
|
+
## [v1.1.0](https://github.com/lostisland/faraday/releases/tag/v1.1.0) (2020-10-17)
|
60
|
+
|
61
|
+
### Features
|
62
|
+
|
63
|
+
* Makes parameters sorting configurable (#1162 @wishdev)
|
64
|
+
* Introduces `flat_encode` option for multipart adapter. (#1163 @iMacTia)
|
65
|
+
* Include request info in exceptions raised by RaiseError Middleware (#1181 @SandroDamilano)
|
66
|
+
|
67
|
+
### Fixes
|
68
|
+
|
69
|
+
* Avoid `last arg as keyword param` warning when building user middleware on Ruby 2.7 (#1153 @dgholz)
|
70
|
+
* Limits net-http-persistent version to < 4.0 (#1156 @iMacTia)
|
71
|
+
* Update `typhoeus` to new stable version (`1.4`) (#1159 @AlexWayfer)
|
72
|
+
* Properly fix test failure with Rack 2.1+. (#1171 @voxik)
|
73
|
+
|
74
|
+
### Documentation
|
75
|
+
|
76
|
+
* Improves documentation on how to contribute to the site by using Docker. (#1175 @iMacTia)
|
77
|
+
* Remove retry_change_requests from documentation (#1185 @stim371)
|
78
|
+
|
79
|
+
### Misc
|
80
|
+
|
81
|
+
* Link from GitHub Actions badge to CI workflow (#1141 @olleolleolle)
|
82
|
+
* Return tests of `Test` adapter (#1147 @AlexWayfer)
|
83
|
+
* Add 1.0 release to wording in CONTRIBUTING (#1155 @olleolleolle)
|
84
|
+
* Fix linting bumping Rubocop to 0.90.0 (#1182 @iMacTia)
|
85
|
+
* Drop `git ls-files` in gemspec (#1183 @utkarsh2102)
|
86
|
+
* Upgrade CI to ruby/setup-ruby (#1187 @gogainda)
|
87
|
+
|
88
|
+
## [v1.0.1](https://github.com/lostisland/faraday/releases/tag/v1.0.1) (2020-03-29)
|
89
|
+
|
90
|
+
### Fixes
|
91
|
+
|
92
|
+
* Use Net::HTTP#start(&block) to ensure closed TCP connections (#1117)
|
93
|
+
* Fully qualify constants to be checked (#1122)
|
94
|
+
* Allows `parse` method to be private/protected in response middleware (#1123)
|
95
|
+
* Encode Spaces in Query Strings as '%20' Instead of '+' (#1125)
|
96
|
+
* Limits rack to v2.0.x (#1127)
|
97
|
+
* Adapter Registry reads also use mutex (#1136)
|
98
|
+
|
99
|
+
### Documentation
|
100
|
+
|
101
|
+
* Retry middleware documentation fix (#1109)
|
102
|
+
* Docs(retry): precise usage of retry-after (#1111)
|
103
|
+
* README: Link the logo to the website (#1112)
|
104
|
+
* Website: add search bar (#1116)
|
105
|
+
* Fix request/response mix-up in docs text (#1132)
|
106
|
+
|
107
|
+
## v1.0
|
108
|
+
|
109
|
+
Features:
|
110
|
+
|
111
|
+
* Add #trace support to Faraday::Connection #861 (@technoweenie)
|
112
|
+
* Add the log formatter that is easy to override and safe to inherit #889 (@prikha)
|
113
|
+
* Support standalone adapters #941 (@iMacTia)
|
114
|
+
* Introduce Faraday::ConflictError for 409 response code #979 (@lucasmoreno)
|
115
|
+
* Add support for setting `read_timeout` option separately #1003 (@springerigor)
|
116
|
+
* Refactor and cleanup timeout settings across adapters #1022 (@technoweenie)
|
117
|
+
* Create ParamPart class to allow multipart posts with JSON content and file upload at the same time #1017 (@jeremy-israel)
|
118
|
+
* Copy UploadIO const -> FilePart for consistency with ParamPart #1018, #1021 (@technoweenie)
|
119
|
+
* Implement streaming responses in the Excon adapter #1026 (@technoweenie)
|
120
|
+
* Add default implementation of `Middleware#close`. #1069 (@ioquatix)
|
121
|
+
* Add `Adapter#close` so that derived classes can call super. #1091 (@ioquatix)
|
122
|
+
* Add log_level option to logger default formatter #1079 (@amrrbakry)
|
123
|
+
* Fix empty array for FlatParamsEncoder `{key: []} -> "key="` #1084 (@mrexox)
|
124
|
+
|
125
|
+
Bugs:
|
126
|
+
|
127
|
+
* Explicitly require date for DateTime library in Retry middleware #844 (@nickpresta)
|
128
|
+
* Refactor Adapter as final endpoints #846 (@iMacTia)
|
129
|
+
* Separate Request and Response bodies in Faraday::Env #847 (@iMacTia)
|
130
|
+
* Implement Faraday::Connection#options to make HTTP requests with the OPTIONS verb. #857 (@technoweenie)
|
131
|
+
* Multipart: Drop Ruby 1.8 String behavior compat #892 (@olleolleolle)
|
132
|
+
* Fix Ruby warnings in Faraday::Options.memoized #962 (@technoweenie)
|
133
|
+
* Allow setting min/max SSL version for a Net::HTTP::Persistent connection #972, #973 (@bdewater, @olleolleolle)
|
134
|
+
* Fix instances of frozen empty string literals #1040 (@BobbyMcWho)
|
135
|
+
* remove temp_proxy and improve proxy tests #1063 (@technoweenie)
|
136
|
+
* improve error initializer consistency #1095 (@technoweenie)
|
137
|
+
|
138
|
+
Misc:
|
139
|
+
|
140
|
+
* Convert minitest suite to RSpec #832 (@iMacTia, with help from @gaynetdinov, @Insti, @technoweenie)
|
141
|
+
* Major effort to update code to RuboCop standards. #854 (@olleolleolle, @iMacTia, @technoweenie, @htwroclau, @jherdman, @Drenmi, @Insti)
|
142
|
+
* Rubocop #1044, #1047 (@BobbyMcWho, @olleolleolle)
|
143
|
+
* Documentation tweaks (@adsteel, @Hubro, @iMacTia, @olleolleolle, @technoweenie)
|
144
|
+
* Update license year #981 (@Kevin-Kawai)
|
145
|
+
* Configure Jekyll plugin jekyll-remote-theme to support Docker usage #999 (@Lewiscowles1986)
|
146
|
+
* Fix Ruby 2.7 warnings #1009 (@tenderlove)
|
147
|
+
* Cleanup adapter connections #1023 (@technoweenie)
|
148
|
+
* Describe clearing cached stubs #1045 (@viraptor)
|
149
|
+
* Add project metadata to the gemspec #1046 (@orien)
|
150
|
+
|
151
|
+
## v0.17.3
|
152
|
+
|
153
|
+
Fixes:
|
154
|
+
|
155
|
+
* Reverts changes in error classes hierarchy. #1092 (@iMacTia)
|
156
|
+
* Fix Ruby 1.9 syntax errors and improve Error class testing #1094 (@BanzaiMan,
|
157
|
+
@mrexox, @technoweenie)
|
158
|
+
|
159
|
+
Misc:
|
160
|
+
|
161
|
+
* Stops using `&Proc.new` for block forwarding. #1083 (@olleolleolle)
|
162
|
+
* Update CI to test against ruby 2.0-2.7 #1087, #1099 (@iMacTia, @olleolleolle,
|
163
|
+
@technoweenie)
|
164
|
+
* require FARADAY_DEPRECATE=warn to show Faraday v1.0 deprecation warnings
|
165
|
+
#1098 (@technoweenie)
|
166
|
+
|
167
|
+
## v0.17.1
|
168
|
+
|
169
|
+
Final release before Faraday v1.0, with important fixes for Ruby 2.7.
|
170
|
+
|
171
|
+
Fixes:
|
172
|
+
|
173
|
+
* RaiseError response middleware raises exception if HTTP client returns a nil
|
174
|
+
status. #1042 (@jonnyom, @BobbyMcWho)
|
175
|
+
|
176
|
+
Misc:
|
177
|
+
|
178
|
+
* Fix Ruby 2.7 warnings (#1009)
|
179
|
+
* Add `Faraday::Deprecate` to warn about upcoming v1.0 changes. (#1054, #1059,
|
180
|
+
#1076, #1077)
|
181
|
+
* Add release notes up to current in CHANGELOG.md (#1066)
|
182
|
+
* Port minimal rspec suite from main branch to run backported tests. (#1058)
|
183
|
+
|
184
|
+
## v0.17.0
|
185
|
+
|
186
|
+
This release is the same as v0.15.4. It was pushed to cover up releases
|
187
|
+
v0.16.0-v0.16.2.
|
188
|
+
|
189
|
+
## v0.15.4
|
190
|
+
|
191
|
+
* Expose `pool_size` as a option for the NetHttpPersistent adapter (#834)
|
192
|
+
|
193
|
+
## v0.15.3
|
194
|
+
|
195
|
+
* Make Faraday::Request serialisable with Marshal. (#803)
|
196
|
+
* Add DEFAULT_EXCEPTIONS constant to Request::Retry (#814)
|
197
|
+
* Add support for Ruby 2.6 Net::HTTP write_timeout (#824)
|
198
|
+
|
199
|
+
## v0.15.2
|
200
|
+
|
201
|
+
* Prevents `Net::HTTP` adapters to retry request internally by setting `max_retries` to 0 if available (Ruby 2.5+). (#799)
|
202
|
+
* Fixes `NestedParamsEncoder` handling of empty array values (#801)
|
203
|
+
|
204
|
+
## v0.15.1
|
205
|
+
|
206
|
+
* NetHttpPersistent adapter better reuse of SSL connections (#793)
|
207
|
+
* Refactor: inline cached_connection (#797)
|
208
|
+
* Logger middleware: use $stdout instead of STDOUT (#794)
|
209
|
+
* Fix: do not memoize/reuse Patron session (#796)
|
210
|
+
|
211
|
+
Also in this release:
|
212
|
+
|
213
|
+
* Allow setting min/max ssl version for Net::HTTP (#792)
|
214
|
+
* Allow setting min/max ssl version for Excon (#795)
|
215
|
+
|
216
|
+
## v0.15.0
|
217
|
+
|
218
|
+
Features:
|
219
|
+
|
220
|
+
* Added retry block option to retry middleware. (#770)
|
221
|
+
* Retry middleware improvements (honour Retry-After header, retry statuses) (#773)
|
222
|
+
* Improve response logger middleware output (#784)
|
223
|
+
|
224
|
+
Fixes:
|
225
|
+
|
226
|
+
* Remove unused class error (#767)
|
227
|
+
* Fix minor typo in README (#760)
|
228
|
+
* Reuse persistent connections when using net-http-persistent (#778)
|
229
|
+
* Fix Retry middleware documentation (#781)
|
230
|
+
* Returns the http response when giving up on retrying by status (#783)
|
231
|
+
|
232
|
+
## v0.14.0
|
233
|
+
|
234
|
+
Features:
|
235
|
+
|
236
|
+
* Allow overriding env proxy #754 (@iMacTia)
|
237
|
+
* Remove legacy Typhoeus adapter #715 (@olleolleolle)
|
238
|
+
* External Typhoeus Adapter Compatibility #748 (@iMacTia)
|
239
|
+
* Warn about missing adapter when making a request #743 (@antstorm)
|
240
|
+
* Faraday::Adapter::Test stubs now support entire urls (with host) #741 (@erik-escobedo)
|
241
|
+
|
242
|
+
Fixes:
|
243
|
+
|
244
|
+
* If proxy is manually provided, this takes priority over `find_proxy` #724 (@iMacTia)
|
245
|
+
* Fixes the behaviour for Excon's open_timeout (not setting write_timeout anymore) #731 (@apachelogger)
|
246
|
+
* Handle all connection timeout messages in Patron #687 (@stayhero)
|
247
|
+
|
248
|
+
## v0.13.1
|
249
|
+
|
250
|
+
* Fixes an incompatibility with Addressable::URI being used as uri_parser
|
251
|
+
|
252
|
+
## v0.13.0
|
253
|
+
|
254
|
+
Features:
|
255
|
+
|
256
|
+
* Dynamically reloads the proxy when performing a request on an absolute domain (#701)
|
257
|
+
* Adapter support for Net::HTTP::Persistent v3.0.0 (#619)
|
258
|
+
|
259
|
+
Fixes:
|
260
|
+
|
261
|
+
* Prefer #hostname over #host. (#714)
|
262
|
+
* Fixes an edge-case issue with response headers parsing (missing HTTP header) (#719)
|
263
|
+
|
264
|
+
## v0.12.2
|
265
|
+
|
266
|
+
* Parse headers from aggregated proxy requests/responses (#681)
|
267
|
+
* Guard against invalid middleware configuration with warning (#685)
|
268
|
+
* Do not use :insecure option by default in Patron (#691)
|
269
|
+
* Fixes an issue with HTTPClient not raising a `Faraday::ConnectionFailed` (#702)
|
270
|
+
* Fixes YAML serialization/deserialization for `Faraday::Utils::Headers` (#690)
|
271
|
+
* Fixes an issue with Options having a nil value (#694)
|
272
|
+
* Fixes an issue with Faraday.default_connection not using Faraday.default_connection_options (#698)
|
273
|
+
* Fixes an issue with Options.merge! and Faraday instrumentation middleware (#710)
|
274
|
+
|
275
|
+
## v0.12.1
|
276
|
+
|
277
|
+
* Fix an issue with Patron tests failing on jruby
|
278
|
+
* Fix an issue with new `rewind_files` feature that was causing an exception when the body was not an Hash
|
279
|
+
* Expose wrapped_exception in all client errors
|
280
|
+
* Add Authentication Section to the ReadMe
|
281
|
+
|
282
|
+
## v0.12.0.1
|
283
|
+
|
284
|
+
* Hotfix release to address an issue with TravisCI deploy on Rubygems
|
285
|
+
|
286
|
+
## v0.12.0
|
287
|
+
|
288
|
+
Features:
|
289
|
+
|
290
|
+
* Proxy feature now relies on Ruby `URI::Generic#find_proxy` and can use `no_proxy` ENV variable (not compatible with ruby < 2.0)
|
291
|
+
* Adds support for `context` request option to pass arbitrary information to middlewares
|
292
|
+
|
293
|
+
Fixes:
|
294
|
+
|
295
|
+
* Fix an issue with options that was causing new options to override defaults ones unexpectedly
|
296
|
+
* Rewind `UploadIO`s on retry to fix a compatibility issue
|
297
|
+
* Make multipart boundary unique
|
298
|
+
* Improvements in `README.md`
|
299
|
+
|
300
|
+
## v0.11.0
|
301
|
+
|
302
|
+
Features:
|
303
|
+
|
304
|
+
* Add `filter` method to Logger middleware
|
305
|
+
* Add support for Ruby2.4 and Minitest 6
|
306
|
+
* Introduce block syntax to customise the adapter
|
307
|
+
|
308
|
+
Fixes:
|
309
|
+
|
310
|
+
* Fix an issue that was allowing to override `default_connection_options` from a connection instance
|
311
|
+
* Fix a bug that was causing newline escape characters ("\n") to be used when building the Authorization header
|
312
|
+
|
313
|
+
## v0.10.1
|
314
|
+
|
315
|
+
- Fix an issue with HTTPClient adapter that was causing the SSL to be reset on every request
|
316
|
+
- Rescue `IOError` instead of specific subclass
|
317
|
+
- `Faraday::Utils::Headers` can now be successfully serialised in YAML
|
318
|
+
- Handle `default_connection_options` set with hash
|
319
|
+
|
320
|
+
## v0.10.0
|
321
|
+
|
322
|
+
Breaking changes:
|
323
|
+
- Drop support for Ruby 1.8
|
324
|
+
|
325
|
+
Features:
|
326
|
+
- Include wrapped exception/reponse in ClientErrors
|
327
|
+
- Add `response.reason_phrase`
|
328
|
+
- Provide option to selectively skip logging request/response headers
|
329
|
+
- Add regex support for pattern matching in `test` adapter
|
330
|
+
|
331
|
+
Fixes:
|
332
|
+
- Add `Faraday.respond_to?` to find methods managed by `method_missing`
|
333
|
+
- em-http: `request.host` instead of `connection.host` should be taken for SSL validations
|
334
|
+
- Allow `default_connection_options` to be merged when options are passed as url parameter
|
335
|
+
- Improve splitting key-value pairs in raw HTTP headers
|
336
|
+
|
337
|
+
## v0.9.2
|
338
|
+
|
339
|
+
Adapters:
|
340
|
+
- Enable gzip compression for httpclient
|
341
|
+
- Fixes default certificate store for httpclient not having default paths.
|
342
|
+
- Make excon adapter compatible with 0.44 excon version
|
343
|
+
- Add compatibility with Patron 0.4.20
|
344
|
+
- Determine default port numbers in Net::HTTP adapters (Addressable compatibility)
|
345
|
+
- em-http: wrap "connection closed by server" as ConnectionFailed type
|
346
|
+
- Wrap Errno::ETIMEDOUT in Faraday::Error::TimeoutError
|
347
|
+
|
348
|
+
Utils:
|
349
|
+
- Add Rack-compatible support for parsing `a[][b]=c` nested queries
|
350
|
+
- Encode nil values in queries different than empty strings. Before: `a=`; now: `a`.
|
351
|
+
- Have `Faraday::Utils::Headers#replace` clear internal key cache
|
352
|
+
- Dup the internal key cache when a Headers hash is copied
|
353
|
+
|
354
|
+
Env and middleware:
|
355
|
+
- Ensure `env` stored on middleware response has reference to the response
|
356
|
+
- Ensure that Response properties are initialized during `on_complete` (VCR compatibility)
|
357
|
+
- Copy request options in Faraday::Connection#dup
|
358
|
+
- Env custom members should be copied by Env.from(env)
|
359
|
+
- Honour per-request `request.options.params_encoder`
|
360
|
+
- Fix `interval_randomness` data type for Retry middleware
|
361
|
+
- Add maximum interval option for Retry middleware
|
362
|
+
|
363
|
+
## v0.9.1
|
364
|
+
|
365
|
+
* Refactor Net:HTTP adapter so that with_net_http_connection can be overridden to allow pooled connections. (@Ben-M)
|
366
|
+
* Add configurable methods that bypass `retry_if` in the Retry request middleware. (@mike-bourgeous)
|
367
|
+
|
368
|
+
## v0.9.0
|
369
|
+
|
370
|
+
* Add HTTPClient adapter (@hakanensari)
|
371
|
+
* Improve Retry handler (@mislav)
|
372
|
+
* Remove autoloading by default (@technoweenie)
|
373
|
+
* Improve internal docs (@technoweenie, @mislav)
|
374
|
+
* Respect user/password in http proxy string (@mislav)
|
375
|
+
* Adapter options are structs. Reinforces consistent options across adapters
|
376
|
+
(@technoweenie)
|
377
|
+
* Stop stripping trailing / off base URLs in a Faraday::Connection. (@technoweenie)
|
378
|
+
* Add a configurable URI parser. (@technoweenie)
|
379
|
+
* Remove need to manually autoload when using the authorization header helpers on `Faraday::Connection`. (@technoweenie)
|
380
|
+
* `Faraday::Adapter::Test` respects the `Faraday::RequestOptions#params_encoder` option. (@technoweenie)
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,235 +1,30 @@
|
|
1
|
-
# Faraday
|
1
|
+
# [][website]
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Faraday supports these adapters:
|
8
|
-
|
9
|
-
* [Net::HTTP][net_http] _(default)_
|
10
|
-
* [Net::HTTP::Persistent][persistent]
|
11
|
-
* [Excon][]
|
12
|
-
* [Typhoeus][]
|
13
|
-
* [Patron][]
|
14
|
-
* [EventMachine][]
|
15
|
-
* [HTTPClient][]
|
16
|
-
|
17
|
-
It also includes a Rack adapter for hitting loaded Rack applications through
|
18
|
-
Rack::Test, and a Test adapter for stubbing requests by hand.
|
19
|
-
|
20
|
-
## API documentation
|
21
|
-
|
22
|
-
Available at [rubydoc.info](http://www.rubydoc.info/gems/faraday).
|
23
|
-
|
24
|
-
## Usage
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
conn = Faraday.new(:url => 'http://sushi.com') do |faraday|
|
28
|
-
faraday.request :url_encoded # form-encode POST params
|
29
|
-
faraday.response :logger # log requests to STDOUT
|
30
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
31
|
-
end
|
32
|
-
|
33
|
-
# Filter sensitive information from logs with a regex matcher
|
34
|
-
|
35
|
-
conn = Faraday.new(:url => 'http://sushi.com/api_key=s3cr3t') do |faraday|
|
36
|
-
faraday.response :logger do | logger |
|
37
|
-
logger.filter(/(api_key=)(\w+)/,'\1[REMOVED]')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
## GET ##
|
42
|
-
|
43
|
-
response = conn.get '/nigiri/sake.json' # GET http://sushi.com/nigiri/sake.json
|
44
|
-
response.body
|
45
|
-
|
46
|
-
conn.get '/nigiri', { :name => 'Maguro' } # GET http://sushi.com/nigiri?name=Maguro
|
47
|
-
|
48
|
-
conn.get do |req| # GET http://sushi.com/search?page=2&limit=100
|
49
|
-
req.url '/search', :page => 2
|
50
|
-
req.params['limit'] = 100
|
51
|
-
end
|
52
|
-
|
53
|
-
## POST ##
|
54
|
-
|
55
|
-
conn.post '/nigiri', { :name => 'Maguro' } # POST "name=maguro" to http://sushi.com/nigiri
|
56
|
-
|
57
|
-
# post payload as JSON instead of "www-form-urlencoded" encoding:
|
58
|
-
conn.post do |req|
|
59
|
-
req.url '/nigiri'
|
60
|
-
req.headers['Content-Type'] = 'application/json'
|
61
|
-
req.body = '{ "name": "Unagi" }'
|
62
|
-
end
|
63
|
-
|
64
|
-
## Per-request options ##
|
65
|
-
|
66
|
-
conn.get do |req|
|
67
|
-
req.url '/search'
|
68
|
-
req.options.timeout = 5 # open/read timeout in seconds
|
69
|
-
req.options.open_timeout = 2 # connection open timeout in seconds
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
If you don't need to set up anything, you can roll with just the default middleware
|
74
|
-
stack and default adapter (see [Faraday::RackBuilder#initialize](https://github.com/lostisland/faraday/blob/master/lib/faraday/rack_builder.rb)):
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
response = Faraday.get 'http://sushi.com/nigiri/sake.json'
|
78
|
-
```
|
79
|
-
|
80
|
-
### Changing how parameters are serialized
|
81
|
-
|
82
|
-
Sometimes you need to send the same URL parameter multiple times with different
|
83
|
-
values. This requires manually setting the parameter encoder and can be done on
|
84
|
-
either per-connection or per-request basis.
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
# per-connection setting
|
88
|
-
conn = Faraday.new :request => { :params_encoder => Faraday::FlatParamsEncoder }
|
89
|
-
|
90
|
-
conn.get do |req|
|
91
|
-
# per-request setting:
|
92
|
-
# req.options.params_encoder = my_encoder
|
93
|
-
req.params['roll'] = ['california', 'philadelphia']
|
94
|
-
end
|
95
|
-
# GET 'http://sushi.com?roll=california&roll=philadelphia'
|
96
|
-
```
|
97
|
-
|
98
|
-
The value of Faraday `params_encoder` can be any object that responds to:
|
99
|
-
|
100
|
-
* `encode(hash) #=> String`
|
101
|
-
* `decode(string) #=> Hash`
|
3
|
+
[](https://rubygems.org/gems/faraday)
|
4
|
+
[](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
|
5
|
+
[](https://gitter.im/lostisland/faraday?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
102
6
|
|
103
|
-
The encoder will affect both how query strings are processed and how POST bodies
|
104
|
-
get serialized. The default encoder is Faraday::NestedParamsEncoder.
|
105
7
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
first middleware on the list wraps all others, while the last middleware is the
|
110
|
-
innermost one, so that must be the adapter.
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
Faraday.new(...) do |conn|
|
114
|
-
# POST/PUT params encoders:
|
115
|
-
conn.request :multipart
|
116
|
-
conn.request :url_encoded
|
117
|
-
|
118
|
-
conn.adapter :net_http
|
119
|
-
end
|
120
|
-
```
|
121
|
-
|
122
|
-
This request middleware setup affects POST/PUT requests in the following way:
|
123
|
-
|
124
|
-
1. `Request::Multipart` checks for files in the payload, otherwise leaves
|
125
|
-
everything untouched;
|
126
|
-
2. `Request::UrlEncoded` encodes as "application/x-www-form-urlencoded" if not
|
127
|
-
already encoded or of another type
|
128
|
-
|
129
|
-
Swapping middleware means giving the other priority. Specifying the
|
130
|
-
"Content-Type" for the request is explicitly stating which middleware should
|
131
|
-
process it.
|
132
|
-
|
133
|
-
Examples:
|
134
|
-
|
135
|
-
```ruby
|
136
|
-
# uploading a file:
|
137
|
-
payload[:profile_pic] = Faraday::UploadIO.new('/path/to/avatar.jpg', 'image/jpeg')
|
138
|
-
|
139
|
-
# "Multipart" middleware detects files and encodes with "multipart/form-data":
|
140
|
-
conn.put '/profile', payload
|
141
|
-
```
|
142
|
-
|
143
|
-
## Writing middleware
|
144
|
-
|
145
|
-
Middleware are classes that implement a `call` instance method. They hook into
|
146
|
-
the request/response cycle.
|
147
|
-
|
148
|
-
```ruby
|
149
|
-
def call(request_env)
|
150
|
-
# do something with the request
|
151
|
-
# request_env[:request_headers].merge!(...)
|
152
|
-
|
153
|
-
@app.call(request_env).on_complete do |response_env|
|
154
|
-
# do something with the response
|
155
|
-
# response_env[:response_headers].merge!(...)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
```
|
159
|
-
|
160
|
-
It's important to do all processing of the response only in the `on_complete`
|
161
|
-
block. This enables middleware to work in parallel mode where requests are
|
162
|
-
asynchronous.
|
163
|
-
|
164
|
-
The `env` is a hash with symbol keys that contains info about the request and,
|
165
|
-
later, response. Some keys are:
|
166
|
-
|
167
|
-
```
|
168
|
-
# request phase
|
169
|
-
:method - :get, :post, ...
|
170
|
-
:url - URI for the current request; also contains GET parameters
|
171
|
-
:body - POST parameters for :post/:put requests
|
172
|
-
:request_headers
|
173
|
-
|
174
|
-
# response phase
|
175
|
-
:status - HTTP response status code, such as 200
|
176
|
-
:body - the response body
|
177
|
-
:response_headers
|
178
|
-
```
|
179
|
-
|
180
|
-
## Using Faraday for testing
|
181
|
-
|
182
|
-
```ruby
|
183
|
-
# It's possible to define stubbed request outside a test adapter block.
|
184
|
-
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
|
185
|
-
stub.get('/tamago') { |env| [200, {}, 'egg'] }
|
186
|
-
end
|
187
|
-
|
188
|
-
# You can pass stubbed request to the test adapter or define them in a block
|
189
|
-
# or a combination of the two.
|
190
|
-
test = Faraday.new do |builder|
|
191
|
-
builder.adapter :test, stubs do |stub|
|
192
|
-
stub.get('/ebi') { |env| [ 200, {}, 'shrimp' ]}
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
# It's also possible to stub additional requests after the connection has
|
197
|
-
# been initialized. This is useful for testing.
|
198
|
-
stubs.get('/uni') { |env| [ 200, {}, 'urchin' ]}
|
199
|
-
|
200
|
-
resp = test.get '/tamago'
|
201
|
-
resp.body # => 'egg'
|
202
|
-
resp = test.get '/ebi'
|
203
|
-
resp.body # => 'shrimp'
|
204
|
-
resp = test.get '/uni'
|
205
|
-
resp.body # => 'urchin'
|
206
|
-
resp = test.get '/else' #=> raises "no such stub" error
|
207
|
-
|
208
|
-
# If you like, you can treat your stubs as mocks by verifying that all of
|
209
|
-
# the stubbed calls were made. NOTE that this feature is still fairly
|
210
|
-
# experimental: It will not verify the order or count of any stub, only that
|
211
|
-
# it was called once during the course of the test.
|
212
|
-
stubs.verify_stubbed_calls
|
213
|
-
```
|
8
|
+
Faraday is an HTTP client library that provides a common interface over many
|
9
|
+
adapters (such as Net::HTTP) and embraces the concept of Rack middleware when
|
10
|
+
processing the request/response cycle.
|
214
11
|
|
215
|
-
##
|
12
|
+
## Getting Started
|
216
13
|
|
217
|
-
|
218
|
-
|
14
|
+
The best starting point is the [Faraday Website][website], with its introduction and explanation.
|
15
|
+
Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally.
|
219
16
|
|
220
17
|
## Supported Ruby versions
|
221
18
|
|
222
|
-
This library aims to support and is [tested against][
|
19
|
+
This library aims to support and is [tested against][actions] the following Ruby
|
223
20
|
implementations:
|
224
21
|
|
225
|
-
* Ruby
|
226
|
-
* [JRuby][] 1.7+
|
227
|
-
* [Rubinius][] 2+
|
22
|
+
* Ruby 2.4+
|
228
23
|
|
229
24
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
230
25
|
|
231
26
|
This library may inadvertently work (or seem to work) on other Ruby
|
232
|
-
implementations, however support will only be provided for the versions listed
|
27
|
+
implementations and versions, however support will only be provided for the versions listed
|
233
28
|
above.
|
234
29
|
|
235
30
|
If you would like this library to support another Ruby version, you may
|
@@ -239,19 +34,20 @@ implementation, you will be responsible for providing patches in a timely
|
|
239
34
|
fashion. If critical issues for a particular implementation exist at the time
|
240
35
|
of a major release, support for that Ruby version may be dropped.
|
241
36
|
|
242
|
-
##
|
37
|
+
## Contribute
|
38
|
+
|
39
|
+
Do you want to contribute to Faraday?
|
40
|
+
Open the issues page and check for the `help wanted` label!
|
41
|
+
But before you start coding, please read our [Contributing Guide][contributing]
|
243
42
|
|
244
|
-
Copyright
|
245
|
-
|
43
|
+
## Copyright
|
44
|
+
© 2009 - 2020, the [Faraday Team][faraday_team]. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
|
246
45
|
|
247
|
-
[
|
248
|
-
[
|
249
|
-
[
|
250
|
-
[
|
251
|
-
[
|
252
|
-
[patron]: http://toland.github.io/patron/
|
253
|
-
[eventmachine]: https://github.com/igrigorik/em-http-request#readme
|
254
|
-
[httpclient]: https://github.com/nahi/httpclient
|
46
|
+
[website]: https://lostisland.github.io/faraday
|
47
|
+
[faraday_team]: https://lostisland.github.io/faraday/team
|
48
|
+
[contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
|
49
|
+
[apidoc]: https://www.rubydoc.info/github/lostisland/faraday
|
50
|
+
[actions]: https://github.com/lostisland/faraday/actions
|
255
51
|
[jruby]: http://jruby.org/
|
256
52
|
[rubinius]: http://rubini.us/
|
257
53
|
[license]: LICENSE.md
|