faraday 1.0.0 → 2.9.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 +4 -4
- data/CHANGELOG.md +299 -1
- data/LICENSE.md +1 -1
- data/README.md +35 -23
- data/Rakefile +3 -1
- data/examples/client_spec.rb +68 -14
- data/examples/client_test.rb +80 -15
- data/lib/faraday/adapter/test.rb +117 -52
- data/lib/faraday/adapter.rb +6 -20
- data/lib/faraday/adapter_registry.rb +3 -1
- data/lib/faraday/connection.rb +73 -132
- data/lib/faraday/encoders/flat_params_encoder.rb +9 -2
- data/lib/faraday/encoders/nested_params_encoder.rb +20 -8
- data/lib/faraday/error.rb +37 -8
- data/lib/faraday/logging/formatter.rb +28 -15
- data/lib/faraday/methods.rb +6 -0
- data/lib/faraday/middleware.rb +17 -5
- data/lib/faraday/middleware_registry.rb +17 -63
- data/lib/faraday/options/connection_options.rb +7 -6
- data/lib/faraday/options/env.rb +85 -62
- data/lib/faraday/options/proxy_options.rb +11 -3
- data/lib/faraday/options/request_options.rb +7 -6
- data/lib/faraday/options/ssl_options.rb +56 -45
- data/lib/faraday/options.rb +11 -14
- data/lib/faraday/rack_builder.rb +35 -32
- data/lib/faraday/request/authorization.rb +37 -36
- data/lib/faraday/request/instrumentation.rb +5 -1
- data/lib/faraday/request/json.rb +70 -0
- data/lib/faraday/request/url_encoded.rb +8 -2
- data/lib/faraday/request.rb +22 -29
- data/lib/faraday/response/json.rb +73 -0
- data/lib/faraday/response/logger.rb +8 -4
- data/lib/faraday/response/raise_error.rb +41 -3
- data/lib/faraday/response.rb +10 -23
- data/lib/faraday/utils/headers.rb +9 -4
- data/lib/faraday/utils.rb +22 -10
- data/lib/faraday/version.rb +5 -0
- data/lib/faraday.rb +49 -58
- data/spec/faraday/adapter/test_spec.rb +442 -0
- data/spec/faraday/connection_spec.rb +207 -90
- data/spec/faraday/error_spec.rb +45 -5
- data/spec/faraday/middleware_registry_spec.rb +31 -0
- data/spec/faraday/middleware_spec.rb +50 -6
- data/spec/faraday/options/env_spec.rb +8 -2
- data/spec/faraday/options/options_spec.rb +1 -1
- data/spec/faraday/options/proxy_options_spec.rb +15 -0
- data/spec/faraday/params_encoders/flat_spec.rb +8 -0
- data/spec/faraday/params_encoders/nested_spec.rb +16 -0
- data/spec/faraday/rack_builder_spec.rb +171 -50
- data/spec/faraday/request/authorization_spec.rb +54 -24
- data/spec/faraday/request/instrumentation_spec.rb +5 -7
- data/spec/faraday/request/json_spec.rb +199 -0
- data/spec/faraday/request/url_encoded_spec.rb +25 -2
- data/spec/faraday/request_spec.rb +11 -10
- data/spec/faraday/response/json_spec.rb +189 -0
- data/spec/faraday/response/logger_spec.rb +38 -0
- data/spec/faraday/response/raise_error_spec.rb +105 -0
- data/spec/faraday/response_spec.rb +3 -1
- data/spec/faraday/utils/headers_spec.rb +22 -4
- data/spec/faraday/utils_spec.rb +63 -1
- data/spec/faraday_spec.rb +8 -4
- data/spec/spec_helper.rb +6 -5
- data/spec/support/fake_safe_buffer.rb +1 -1
- data/spec/support/helper_methods.rb +0 -37
- data/spec/support/shared_examples/adapter.rb +4 -3
- data/spec/support/shared_examples/request_method.rb +60 -31
- metadata +19 -44
- data/UPGRADING.md +0 -55
- data/lib/faraday/adapter/em_http.rb +0 -285
- data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -62
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -69
- data/lib/faraday/adapter/em_synchrony.rb +0 -150
- data/lib/faraday/adapter/excon.rb +0 -124
- data/lib/faraday/adapter/httpclient.rb +0 -151
- data/lib/faraday/adapter/net_http.rb +0 -209
- data/lib/faraday/adapter/net_http_persistent.rb +0 -91
- data/lib/faraday/adapter/patron.rb +0 -132
- data/lib/faraday/adapter/rack.rb +0 -75
- data/lib/faraday/adapter/typhoeus.rb +0 -15
- data/lib/faraday/autoload.rb +0 -95
- data/lib/faraday/dependency_loader.rb +0 -37
- data/lib/faraday/file_part.rb +0 -128
- data/lib/faraday/param_part.rb +0 -53
- data/lib/faraday/request/basic_authentication.rb +0 -20
- data/lib/faraday/request/multipart.rb +0 -99
- data/lib/faraday/request/retry.rb +0 -239
- data/lib/faraday/request/token_authentication.rb +0 -20
- data/spec/faraday/adapter/em_http_spec.rb +0 -47
- data/spec/faraday/adapter/em_synchrony_spec.rb +0 -16
- data/spec/faraday/adapter/excon_spec.rb +0 -49
- data/spec/faraday/adapter/httpclient_spec.rb +0 -73
- data/spec/faraday/adapter/net_http_persistent_spec.rb +0 -57
- data/spec/faraday/adapter/net_http_spec.rb +0 -64
- data/spec/faraday/adapter/patron_spec.rb +0 -18
- data/spec/faraday/adapter/rack_spec.rb +0 -8
- data/spec/faraday/adapter/typhoeus_spec.rb +0 -7
- data/spec/faraday/composite_read_io_spec.rb +0 -80
- data/spec/faraday/request/multipart_spec.rb +0 -274
- data/spec/faraday/request/retry_spec.rb +0 -242
- data/spec/faraday/response/middleware_spec.rb +0 -52
- data/spec/support/webmock_rack_app.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8daafc733cd0bf7b27c3ec39dcca14da1dd4ad6bf28d72e96c6c7c214d4992e1
|
4
|
+
data.tar.gz: 8b5ce62606f14fd89a64adbe24099ef53067c98444419bfe58b0b986501dae5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 980d8a35587b2ead1383ac7cd7f8649c193a6d9685c0d69c97f9be4937a18deeef7858d50d2c20649774ac97293d0dc6d4b51049cb40e4f4422132d0c58f372b
|
7
|
+
data.tar.gz: a02dbd0bd5d2670728f39f2a673b385abda43d7449cb204bff10878e562a179c2de595665096dbc24c4d183990a0417c7386159afb952955806c0ea3321bf5fe
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,297 @@
|
|
1
1
|
# Faraday Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## The changelog has moved!
|
4
|
+
|
5
|
+
This file is not being updated anymore. Instead, please check the [Releases](https://github.com/lostisland/faraday/releases) page.
|
6
|
+
|
7
|
+
## [2.2.0](https://github.com/lostisland/faraday/compare/v2.1.0...v2.2.0) (2022-02-03)
|
8
|
+
|
9
|
+
* Reintroduce the possibility to register middleware with symbols, strings or procs in [#1391](https://github.com/lostisland/faraday/pull/1391)
|
10
|
+
|
11
|
+
## [2.1.0](https://github.com/lostisland/faraday/compare/v2.0.1...v2.1.0) (2022-01-15)
|
12
|
+
|
13
|
+
* Fix test adapter thread safety by @iMacTia in [#1380](https://github.com/lostisland/faraday/pull/1380)
|
14
|
+
* Add default adapter options by @hirasawayuki in [#1382](https://github.com/lostisland/faraday/pull/1382)
|
15
|
+
* CI: Add Ruby 3.1 to matrix by @petergoldstein in [#1374](https://github.com/lostisland/faraday/pull/1374)
|
16
|
+
* docs: fix regex pattern in logger.md examples by @hirasawayuki in [#1378](https://github.com/lostisland/faraday/pull/1378)
|
17
|
+
|
18
|
+
## [2.0.1](https://github.com/lostisland/faraday/compare/v2.0.0...v2.0.1) (2022-01-05)
|
19
|
+
|
20
|
+
* Re-add `faraday-net_http` as default adapter by @iMacTia in [#1366](https://github.com/lostisland/faraday/pull/1366)
|
21
|
+
* Updated sample format in UPGRADING.md by @vimutter in [#1361](https://github.com/lostisland/faraday/pull/1361)
|
22
|
+
* docs: Make UPGRADING examples more copyable by @olleolleolle in [#1363](https://github.com/lostisland/faraday/pull/1363)
|
23
|
+
|
24
|
+
## [2.0.0](https://github.com/lostisland/faraday/compare/v1.8.0...v2.0.0) (2022-01-04)
|
25
|
+
|
26
|
+
The next major release is here, and it comes almost 2 years after the release of v1.0!
|
27
|
+
|
28
|
+
This release changes the way you use Faraday and embraces a new paradigm of Faraday as an ecosystem, rather than a library.
|
29
|
+
|
30
|
+
What does that mean? It means that Faraday is less of a bundled tool and more of a framework for the community to build on top of.
|
31
|
+
|
32
|
+
As a result, all adapters and some middleware have moved out and are now shipped as standalone gems 🙌!
|
33
|
+
|
34
|
+
But this doesn't mean that upgrading from Faraday 1.x to Faraday 2.0 should be hard, in fact we've listed everything you need to do in the [UPGRADING.md](https://github.com/lostisland/faraday/blob/main/UPGRADING.md) doc.
|
35
|
+
|
36
|
+
Moreover, we've setup a new [awesome-faraday](https://github.com/lostisland/awesome-faraday) repository that will showcase a curated list of adapters and middleware 😎.
|
37
|
+
|
38
|
+
This release was the result of the efforts of the core team and all the contributors, new and old, that have helped achieve this milestone 👏.
|
39
|
+
|
40
|
+
## What's Changed
|
41
|
+
|
42
|
+
* Autoloading, dependency loading and middleware registry cleanup by @iMacTia in [#1301](https://github.com/lostisland/faraday/pull/1301)
|
43
|
+
* Move JSON middleware (request and response) from faraday_middleware by @iMacTia in [#1300](https://github.com/lostisland/faraday/pull/1300)
|
44
|
+
* Remove deprecated `Faraday::Request#method` by @olleolleolle in [#1303](https://github.com/lostisland/faraday/pull/1303)
|
45
|
+
* Remove deprecated `Faraday::UploadIO` by @iMacTia in [#1307](https://github.com/lostisland/faraday/pull/1307)
|
46
|
+
* [1.x] Deprecate Authorization helpers in `Faraday::Connection` by @iMacTia in [#1306](https://github.com/lostisland/faraday/pull/1306)
|
47
|
+
* Drop deprecated auth helpers from Connection and refactor auth middleware by @iMacTia in [#1308](https://github.com/lostisland/faraday/pull/1308)
|
48
|
+
* Add Faraday 1.x examples in authentication.md docs by @iMacTia in [#1320](https://github.com/lostisland/faraday/pull/1320)
|
49
|
+
* Fix passing a URL with embedded basic auth by @iMacTia in [#1324](https://github.com/lostisland/faraday/pull/1324)
|
50
|
+
* Register JSON middleware by @mollerhoj in [#1331](https://github.com/lostisland/faraday/pull/1331)
|
51
|
+
* Retry middleware should handle string exception class name consistently by @jrochkind in [#1334](https://github.com/lostisland/faraday/pull/1334)
|
52
|
+
* Improve request info in exceptions raised by RaiseError Middleware by @willianzocolau in [#1335](https://github.com/lostisland/faraday/pull/1335)
|
53
|
+
* Remove net-http adapter and update docs by @iMacTia in [#1336](https://github.com/lostisland/faraday/pull/1336)
|
54
|
+
* Explain plan for faraday_middleware in UPGRADING.md by @iMacTia in [#1339](https://github.com/lostisland/faraday/pull/1339)
|
55
|
+
* Scripts folder cleanup by @iMacTia in [#1340](https://github.com/lostisland/faraday/pull/1340)
|
56
|
+
* Replace `Hash#merge` with `Utils#deep_merge` for connection options by @xkwd in [#1343](https://github.com/lostisland/faraday/pull/1343)
|
57
|
+
* Callable authorizers by @sled in [#1345](https://github.com/lostisland/faraday/pull/1345)
|
58
|
+
* Default value for exc error by @DariuszMusielak in [#1351](https://github.com/lostisland/faraday/pull/1351)
|
59
|
+
* Don't call `retry_block` unless a retry is going to happen by @jrochkind in [#1350](https://github.com/lostisland/faraday/pull/1350)
|
60
|
+
* Improve documentation for v2 by @iMacTia in [#1353](https://github.com/lostisland/faraday/pull/1353)
|
61
|
+
* Remove default `default_adapter` (yes, you read that right) by @iMacTia in [#1354](https://github.com/lostisland/faraday/pull/1354)
|
62
|
+
* Remove retry middleware by @iMacTia in [#1356](https://github.com/lostisland/faraday/pull/1356)
|
63
|
+
* Remove multipart middleware and all its documentation and tests by @iMacTia in [#1357](https://github.com/lostisland/faraday/pull/1357)
|
64
|
+
|
65
|
+
## [1.9.3](https://github.com/lostisland/faraday/compare/v1.9.2...v1.9.3) (2022-01-06)
|
66
|
+
|
67
|
+
* Re-add support for Ruby 2.4+ by @iMacTia in [#1371](https://github.com/lostisland/faraday/pull/1371)
|
68
|
+
|
69
|
+
## [1.9.2](https://github.com/lostisland/faraday/compare/v1.9.1...v1.9.2) (2022-01-06)
|
70
|
+
|
71
|
+
* Add alias with legacy name to gemified middleware by @iMacTia in [#1372](https://github.com/lostisland/faraday/pull/1372)
|
72
|
+
|
73
|
+
## [1.9.1](https://github.com/lostisland/faraday/compare/v1.9.0...v1.9.1) (2022-01-06)
|
74
|
+
|
75
|
+
* Update adapter dependencies in Gemspec by @iMacTia in [#1370](https://github.com/lostisland/faraday/pull/1370)
|
76
|
+
|
77
|
+
## [1.9.0](https://github.com/lostisland/faraday/compare/v1.8.0...v1.9.0) (2022-01-06)
|
78
|
+
|
79
|
+
* Use external multipart and retry middleware by @iMacTia in [#1367](https://github.com/lostisland/faraday/pull/1367)
|
80
|
+
|
81
|
+
## [1.8.0](https://github.com/lostisland/faraday/releases/tag/v1.8.0) (2021-09-18)
|
82
|
+
|
83
|
+
### Features
|
84
|
+
|
85
|
+
* Backport authorization procs (#1322, @jarl-dk)
|
86
|
+
|
87
|
+
## [v1.7.0](https://github.com/lostisland/faraday/releases/tag/v1.7.0) (2021-08-09)
|
88
|
+
|
89
|
+
### Features
|
90
|
+
|
91
|
+
* Add strict_mode to Test::Stubs (#1298, @yykamei)
|
92
|
+
|
93
|
+
## [v1.6.0](https://github.com/lostisland/faraday/releases/tag/v1.6.0) (2021-08-01)
|
94
|
+
|
95
|
+
### Misc
|
96
|
+
|
97
|
+
* Use external Rack adapter (#1296, @iMacTia)
|
98
|
+
|
99
|
+
## [v1.5.1](https://github.com/lostisland/faraday/releases/tag/v1.5.1) (2021-07-11)
|
100
|
+
|
101
|
+
### Fixes
|
102
|
+
|
103
|
+
* Fix JRuby incompatibility after moving out EM adapters (#1294, @ahorek)
|
104
|
+
|
105
|
+
### Documentation
|
106
|
+
|
107
|
+
* Update YARD to follow RackBuilder (#1292, @kachick)
|
108
|
+
|
109
|
+
## [v1.5.0](https://github.com/lostisland/faraday/releases/tag/v1.5.0) (2021-07-04)
|
110
|
+
|
111
|
+
### Misc
|
112
|
+
|
113
|
+
* Use external httpclient adapter (#1289, @iMacTia)
|
114
|
+
* Use external patron adapter (#1290, @iMacTia)
|
115
|
+
|
116
|
+
## [v1.4.3](https://github.com/lostisland/faraday/releases/tag/v1.4.3) (2021-06-24)
|
117
|
+
|
118
|
+
### Fixes
|
119
|
+
|
120
|
+
* Silence warning (#1286, @gurgeous)
|
121
|
+
* Always dup url_prefix in Connection#build_exclusive_url (#1288, @alexeyds)
|
122
|
+
|
123
|
+
## [v1.4.2](https://github.com/lostisland/faraday/releases/tag/v1.4.2) (2021-05-22)
|
124
|
+
|
125
|
+
### Fixes
|
126
|
+
* Add proxy setting when url_prefix is changed (#1276, @ci)
|
127
|
+
* Default proxy scheme to http:// if necessary, fixes #1282 (#1283, @gurgeous)
|
128
|
+
|
129
|
+
### Documentation
|
130
|
+
* Improve introduction page (#1273, @gurgeous)
|
131
|
+
* Docs: add more middleware examples (#1277, @gurgeous)
|
132
|
+
|
133
|
+
### Misc
|
134
|
+
* Use external `em_http` and `em_synchrony` adapters (#1274, @iMacTia)
|
135
|
+
|
136
|
+
## [v1.4.1](https://github.com/lostisland/faraday/releases/tag/v1.4.1) (2021-04-18)
|
137
|
+
|
138
|
+
### Fixes
|
139
|
+
|
140
|
+
* Fix dependencies from external adapter gems (#1269, @iMacTia)
|
141
|
+
|
142
|
+
## [v1.4.0](https://github.com/lostisland/faraday/releases/tag/v1.4.0) (2021-04-16)
|
143
|
+
|
144
|
+
### Highlights
|
145
|
+
|
146
|
+
With this release, we continue the work of gradually moving out adapters into their own gems 🎉
|
147
|
+
Thanks to @MikeRogers0 for helping the Faraday team in progressing with this quest 👏
|
148
|
+
|
149
|
+
And thanks to @olleolleolle efforts, Faraday is becoming more inclusive than ever 🤗
|
150
|
+
Faraday's `master` branch has been renamed into `main`, we have an official policy on inclusive language and even a rubocop plugin to check for non-inclusive words ❤️!
|
151
|
+
Checkout the "Misc" section below for more details 🙌 !
|
152
|
+
|
153
|
+
### Fixes
|
154
|
+
|
155
|
+
* Fix NoMethodError undefined method 'coverage' (#1255, @Maroo-b)
|
156
|
+
|
157
|
+
### Documentation
|
158
|
+
|
159
|
+
* Some docs on EventMachine adapters. (#1232, @damau)
|
160
|
+
* CONTRIBUTING: Fix grammar and layout (#1261, @olleolleolle)
|
161
|
+
|
162
|
+
### Misc
|
163
|
+
|
164
|
+
* Replacing Net::HTTP::Persistent with faraday-net_http_persistent (#1250, @MikeRogers0)
|
165
|
+
* CI: Configure the regenerated Coveralls token (#1256, @olleolleolle)
|
166
|
+
* Replace Excon adapter with Faraday::Excon gem, and fix autoloading issue with Faraday::NetHttpPersistent (#1257, @iMacTia)
|
167
|
+
* Drop CodeClimate (#1259, @olleolleolle)
|
168
|
+
* CI: Rename default branch to main (#1263, @olleolleolle)
|
169
|
+
* Drop RDoc support file .document (#1264, @olleolleolle, @iMacTia)
|
170
|
+
* CONTRIBUTING: add a policy on inclusive language (#1262, @olleolleolle)
|
171
|
+
* Add rubocop-inclusivity (#1267, @olleolleolle, @iMacTia)
|
172
|
+
|
173
|
+
## [v1.3.1](https://github.com/lostisland/faraday/releases/tag/v1.3.1) (2021-04-16)
|
174
|
+
|
175
|
+
### Fixes
|
176
|
+
|
177
|
+
* Escape colon in path segment (#1237, @yarafan)
|
178
|
+
* Handle IPv6 address String on Faraday::Connection#proxy_from_env (#1252, @cosmo0920)
|
179
|
+
|
180
|
+
### Documentation
|
181
|
+
|
182
|
+
* Fix broken Rubydoc.info links (#1236, @nickcampbell18)
|
183
|
+
* Add httpx to list of external adapters (#1246, @HoneyryderChuck)
|
184
|
+
|
185
|
+
### Misc
|
186
|
+
|
187
|
+
* Refactor CI to remove duplicated line (#1230, @tricknotes)
|
188
|
+
* Gemspec: Pick a good ruby2_keywords release (#1241, @olleolleolle)
|
189
|
+
|
190
|
+
## [v1.3.0](https://github.com/lostisland/faraday/releases/tag/v1.3.0) (2020-12-31)
|
191
|
+
|
192
|
+
### Highlights
|
193
|
+
Faraday v1.3.0 is the first release to officially support Ruby 3.0 in the CI pipeline 🎉 🍾!
|
194
|
+
|
195
|
+
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) 🎊!
|
196
|
+
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!
|
197
|
+
|
198
|
+
This is a huge step towards are Faraday v2.0 objective of pushing adapters and middleware into separate gems.
|
199
|
+
Many thanks to the Faraday Team, @JanDintel and everyone who attended the [ROSS Conf remote event](https://www.rossconf.io/event/remote/)
|
200
|
+
|
201
|
+
### Features
|
202
|
+
|
203
|
+
* Improves consistency with Faraday::Error and Faraday::RaiseError (#1229, @qsona, @iMacTia)
|
204
|
+
|
205
|
+
### Fixes
|
206
|
+
|
207
|
+
* Don't assign to global ::Timer (#1227, @bpo)
|
208
|
+
|
209
|
+
### Documentation
|
210
|
+
|
211
|
+
* CHANGELOG: add releases after 1.0 (#1225, @olleolleolle)
|
212
|
+
* Improves retry middleware documentation. (#1228, @iMacTia)
|
213
|
+
|
214
|
+
### Misc
|
215
|
+
|
216
|
+
* Move out Net::HTTP adapter (#1222, @JanDintel, @iMacTia)
|
217
|
+
* Adds Ruby 3.0 to CI Matrix (#1226, @iMacTia)
|
218
|
+
|
219
|
+
|
220
|
+
## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
|
221
|
+
|
222
|
+
### Features
|
223
|
+
|
224
|
+
* Introduces `on_request` and `on_complete` methods in `Faraday::Middleware`. (#1194, @iMacTia)
|
225
|
+
|
226
|
+
### Fixes
|
227
|
+
|
228
|
+
* Require 'date' to avoid retry exception (#1206, @rustygeldmacher)
|
229
|
+
* Fix rdebug recursion issue (#1205, @native-api)
|
230
|
+
* Update call to `em_http_ssl_patch` (#1202, @kylekeesling)
|
231
|
+
* `EmHttp` adapter: drop superfluous loaded? check (#1213, @olleolleolle)
|
232
|
+
* Avoid 1 use of keyword hackery (#1211, @grosser)
|
233
|
+
* Fix #1219 `Net::HTTP` still uses env proxy (#1221, @iMacTia)
|
234
|
+
|
235
|
+
### Documentation
|
236
|
+
|
237
|
+
* Add comment in gemspec to explain exposure of `examples` and `spec` folders. (#1192, @iMacTia)
|
238
|
+
* Adapters, how to create them (#1193, @olleolleolle)
|
239
|
+
* Update documentation on using the logger (#1196, @tijmenb)
|
240
|
+
* Adjust the retry documentation and spec to align with implementation (#1198, @nbeyer)
|
241
|
+
|
242
|
+
### Misc
|
243
|
+
|
244
|
+
* Test against ruby head (#1208, @grosser)
|
245
|
+
|
246
|
+
## [v1.1.0](https://github.com/lostisland/faraday/releases/tag/v1.1.0) (2020-10-17)
|
247
|
+
|
248
|
+
### Features
|
249
|
+
|
250
|
+
* Makes parameters sorting configurable (#1162 @wishdev)
|
251
|
+
* Introduces `flat_encode` option for multipart adapter. (#1163 @iMacTia)
|
252
|
+
* Include request info in exceptions raised by RaiseError Middleware (#1181 @SandroDamilano)
|
253
|
+
|
254
|
+
### Fixes
|
255
|
+
|
256
|
+
* Avoid `last arg as keyword param` warning when building user middleware on Ruby 2.7 (#1153 @dgholz)
|
257
|
+
* Limits net-http-persistent version to < 4.0 (#1156 @iMacTia)
|
258
|
+
* Update `typhoeus` to new stable version (`1.4`) (#1159 @AlexWayfer)
|
259
|
+
* Properly fix test failure with Rack 2.1+. (#1171 @voxik)
|
260
|
+
|
261
|
+
### Documentation
|
262
|
+
|
263
|
+
* Improves documentation on how to contribute to the site by using Docker. (#1175 @iMacTia)
|
264
|
+
* Remove retry_change_requests from documentation (#1185 @stim371)
|
265
|
+
|
266
|
+
### Misc
|
267
|
+
|
268
|
+
* Link from GitHub Actions badge to CI workflow (#1141 @olleolleolle)
|
269
|
+
* Return tests of `Test` adapter (#1147 @AlexWayfer)
|
270
|
+
* Add 1.0 release to wording in CONTRIBUTING (#1155 @olleolleolle)
|
271
|
+
* Fix linting bumping Rubocop to 0.90.0 (#1182 @iMacTia)
|
272
|
+
* Drop `git ls-files` in gemspec (#1183 @utkarsh2102)
|
273
|
+
* Upgrade CI to ruby/setup-ruby (#1187 @gogainda)
|
274
|
+
|
275
|
+
## [v1.0.1](https://github.com/lostisland/faraday/releases/tag/v1.0.1) (2020-03-29)
|
276
|
+
|
277
|
+
### Fixes
|
278
|
+
|
279
|
+
* Use Net::HTTP#start(&block) to ensure closed TCP connections (#1117)
|
280
|
+
* Fully qualify constants to be checked (#1122)
|
281
|
+
* Allows `parse` method to be private/protected in response middleware (#1123)
|
282
|
+
* Encode Spaces in Query Strings as '%20' Instead of '+' (#1125)
|
283
|
+
* Limits rack to v2.0.x (#1127)
|
284
|
+
* Adapter Registry reads also use mutex (#1136)
|
285
|
+
|
286
|
+
### Documentation
|
287
|
+
|
288
|
+
* Retry middleware documentation fix (#1109)
|
289
|
+
* Docs(retry): precise usage of retry-after (#1111)
|
290
|
+
* README: Link the logo to the website (#1112)
|
291
|
+
* Website: add search bar (#1116)
|
292
|
+
* Fix request/response mix-up in docs text (#1132)
|
293
|
+
|
294
|
+
## [v1.0](https://github.com/lostisland/faraday/releases/tag/v1.0.0) (2020-01-22)
|
4
295
|
|
5
296
|
Features:
|
6
297
|
|
@@ -44,6 +335,13 @@ Misc:
|
|
44
335
|
* Describe clearing cached stubs #1045 (@viraptor)
|
45
336
|
* Add project metadata to the gemspec #1046 (@orien)
|
46
337
|
|
338
|
+
## v0.17.4
|
339
|
+
|
340
|
+
Fixes:
|
341
|
+
|
342
|
+
* NetHttp adapter: wrap Errno::EADDRNOTAVAIL (#1114, @embs)
|
343
|
+
* Fix === for subclasses of deprecated classes (#1243, @mervync)
|
344
|
+
|
47
345
|
## v0.17.3
|
48
346
|
|
49
347
|
Fixes:
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,27 +1,41 @@
|
|
1
|
-
# ][website]
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/faraday)
|
4
|
-

|
5
|
-
[](https://codeclimate.com/github/lostisland/faraday/maintainability)
|
7
|
-
[](https://gitter.im/lostisland/faraday?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
4
|
+
[](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
|
5
|
+
[](https://github.com/lostisland/faraday/discussions)
|
8
6
|
|
7
|
+
Faraday is an HTTP client library abstraction layer that provides a common interface over many
|
8
|
+
adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.
|
9
|
+
Take a look at [Awesome Faraday][awesome] for a list of available adapters and middleware.
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
## Why use Faraday?
|
12
|
+
|
13
|
+
Faraday gives you the power of Rack middleware for manipulating HTTP requests and responses,
|
14
|
+
making it easier to build sophisticated API clients or web service libraries that abstract away
|
15
|
+
the details of how HTTP requests are made.
|
16
|
+
|
17
|
+
Faraday comes with a lot of features out of the box, such as:
|
18
|
+
* Support for multiple adapters (Net::HTTP, Typhoeus, Patron, Excon, HTTPClient, and more)
|
19
|
+
* Persistent connections (keep-alive)
|
20
|
+
* Parallel requests
|
21
|
+
* Automatic response parsing (JSON, XML, YAML)
|
22
|
+
* Customization of the request/response cycle with middleware
|
23
|
+
* Support for streaming responses
|
24
|
+
* Support for uploading files
|
25
|
+
* And much more!
|
13
26
|
|
14
27
|
## Getting Started
|
15
28
|
|
16
29
|
The best starting point is the [Faraday Website][website], with its introduction and explanation.
|
17
|
-
Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally.
|
18
30
|
|
19
|
-
|
31
|
+
Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally, or take a look at [Advanced techniques for calling HTTP APIs in Ruby](https://mattbrictson.com/blog/advanced-http-techniques-in-ruby) blog post from [@mattbrictson](https://github.com/mattbrictson) 🚀
|
20
32
|
|
21
|
-
|
22
|
-
implementations:
|
33
|
+
## Supported Ruby versions
|
23
34
|
|
24
|
-
|
35
|
+
This library aims to support and is [tested against][actions] the currently officially supported Ruby
|
36
|
+
implementations. This means that, even without a major release, we could add or drop support for Ruby versions,
|
37
|
+
following their [EOL](https://endoflife.date/ruby).
|
38
|
+
Currently that means we support Ruby 3.0+
|
25
39
|
|
26
40
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
27
41
|
|
@@ -43,13 +57,11 @@ Open the issues page and check for the `help wanted` label!
|
|
43
57
|
But before you start coding, please read our [Contributing Guide][contributing]
|
44
58
|
|
45
59
|
## Copyright
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
52
|
-
[
|
53
|
-
[
|
54
|
-
[rubinius]: http://rubini.us/
|
55
|
-
[license]: LICENSE.md
|
60
|
+
|
61
|
+
© 2009 - 2023, the Faraday Team. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
|
62
|
+
|
63
|
+
[awesome]: https://github.com/lostisland/awesome-faraday/#adapters
|
64
|
+
[website]: https://lostisland.github.io/faraday
|
65
|
+
[contributing]: https://github.com/lostisland/faraday/blob/main/.github/CONTRIBUTING.md
|
66
|
+
[apidoc]: https://www.rubydoc.info/github/lostisland/faraday
|
67
|
+
[actions]: https://github.com/lostisland/faraday/actions
|
data/Rakefile
CHANGED
data/examples/client_spec.rb
CHANGED
@@ -12,54 +12,108 @@ class Client
|
|
12
12
|
@conn = conn
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
res = @conn.get("/#{jname}")
|
15
|
+
def httpbingo(jname, params: {})
|
16
|
+
res = @conn.get("/#{jname}", params)
|
17
17
|
data = JSON.parse(res.body)
|
18
|
-
data['
|
18
|
+
data['origin']
|
19
|
+
end
|
20
|
+
|
21
|
+
def foo(params)
|
22
|
+
res = @conn.post('/foo', JSON.dump(params))
|
23
|
+
res.status
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
|
-
|
27
|
+
RSpec.describe Client do
|
23
28
|
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
|
24
29
|
let(:conn) { Faraday.new { |b| b.adapter(:test, stubs) } }
|
25
30
|
let(:client) { Client.new(conn) }
|
26
31
|
|
27
|
-
it 'parses
|
28
|
-
stubs.get('/
|
32
|
+
it 'parses origin' do
|
33
|
+
stubs.get('/ip') do |env|
|
29
34
|
# optional: you can inspect the Faraday::Env
|
30
|
-
expect(env.url.path).to eq('/
|
35
|
+
expect(env.url.path).to eq('/ip')
|
31
36
|
[
|
32
37
|
200,
|
33
38
|
{ 'Content-Type': 'application/javascript' },
|
34
|
-
'{"
|
39
|
+
'{"origin": "127.0.0.1"}'
|
35
40
|
]
|
36
41
|
end
|
37
42
|
|
38
43
|
# uncomment to trigger stubs.verify_stubbed_calls failure
|
39
44
|
# stubs.get('/unused') { [404, {}, ''] }
|
40
45
|
|
41
|
-
expect(client.
|
46
|
+
expect(client.httpbingo('ip')).to eq('127.0.0.1')
|
42
47
|
stubs.verify_stubbed_calls
|
43
48
|
end
|
44
49
|
|
45
50
|
it 'handles 404' do
|
46
|
-
stubs.get('/
|
51
|
+
stubs.get('/api') do
|
47
52
|
[
|
48
53
|
404,
|
49
54
|
{ 'Content-Type': 'application/javascript' },
|
50
55
|
'{}'
|
51
56
|
]
|
52
57
|
end
|
53
|
-
expect(client.
|
58
|
+
expect(client.httpbingo('api')).to be_nil
|
54
59
|
stubs.verify_stubbed_calls
|
55
60
|
end
|
56
61
|
|
57
62
|
it 'handles exception' do
|
58
|
-
stubs.get('/
|
59
|
-
raise Faraday::ConnectionFailed
|
63
|
+
stubs.get('/api') do
|
64
|
+
raise Faraday::ConnectionFailed
|
60
65
|
end
|
61
66
|
|
62
|
-
expect { client.
|
67
|
+
expect { client.httpbingo('api') }.to raise_error(Faraday::ConnectionFailed)
|
63
68
|
stubs.verify_stubbed_calls
|
64
69
|
end
|
70
|
+
|
71
|
+
context 'When the test stub is run in strict_mode' do
|
72
|
+
let(:stubs) { Faraday::Adapter::Test::Stubs.new(strict_mode: true) }
|
73
|
+
|
74
|
+
it 'verifies the all parameter values are identical' do
|
75
|
+
stubs.get('/api?abc=123') do
|
76
|
+
[
|
77
|
+
200,
|
78
|
+
{ 'Content-Type': 'application/javascript' },
|
79
|
+
'{"origin": "127.0.0.1"}'
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
83
|
+
# uncomment to raise Stubs::NotFound
|
84
|
+
# expect(client.httpbingo('api', params: { abc: 123, foo: 'Kappa' })).to eq('127.0.0.1')
|
85
|
+
expect(client.httpbingo('api', params: { abc: 123 })).to eq('127.0.0.1')
|
86
|
+
stubs.verify_stubbed_calls
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'When the Faraday connection is configured with FlatParamsEncoder' do
|
91
|
+
let(:conn) { Faraday.new(request: { params_encoder: Faraday::FlatParamsEncoder }) { |b| b.adapter(:test, stubs) } }
|
92
|
+
|
93
|
+
it 'handles the same multiple URL parameters' do
|
94
|
+
stubs.get('/api?a=x&a=y&a=z') { [200, { 'Content-Type' => 'application/json' }, '{"origin": "127.0.0.1"}'] }
|
95
|
+
|
96
|
+
# uncomment to raise Stubs::NotFound
|
97
|
+
# expect(client.httpbingo('api', params: { a: %w[x y] })).to eq('127.0.0.1')
|
98
|
+
expect(client.httpbingo('api', params: { a: %w[x y z] })).to eq('127.0.0.1')
|
99
|
+
stubs.verify_stubbed_calls
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'When you want to test the body, you can use a proc as well as string' do
|
104
|
+
it 'tests with a string' do
|
105
|
+
stubs.post('/foo', '{"name":"YK"}') { [200, {}, ''] }
|
106
|
+
|
107
|
+
expect(client.foo(name: 'YK')).to eq 200
|
108
|
+
stubs.verify_stubbed_calls
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'tests with a proc' do
|
112
|
+
check = ->(request_body) { JSON.parse(request_body).slice('name') == { 'name' => 'YK' } }
|
113
|
+
stubs.post('/foo', check) { [200, {}, ''] }
|
114
|
+
|
115
|
+
expect(client.foo(name: 'YK', created_at: Time.now)).to eq 200
|
116
|
+
stubs.verify_stubbed_calls
|
117
|
+
end
|
118
|
+
end
|
65
119
|
end
|