typhoeus 1.6.0 → 1.7.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +228 -1
  3. data/README.md +338 -160
  4. data/UPGRADE.md +29 -0
  5. data/lib/rack/typhoeus/middleware/params_decoder/helper.rb +67 -14
  6. data/lib/rack/typhoeus/middleware/params_decoder.rb +8 -19
  7. data/lib/rack/typhoeus.rb +2 -0
  8. data/lib/typhoeus/adapters/faraday.rb +89 -28
  9. data/lib/typhoeus/cache/dalli.rb +2 -0
  10. data/lib/typhoeus/cache/rails.rb +3 -1
  11. data/lib/typhoeus/cache/redis.rb +2 -0
  12. data/lib/typhoeus/config.rb +51 -7
  13. data/lib/typhoeus/easy_factory.rb +129 -23
  14. data/lib/typhoeus/errors/invalid_option.rb +23 -0
  15. data/lib/typhoeus/errors/no_response.rb +18 -0
  16. data/lib/typhoeus/errors/no_stub.rb +8 -1
  17. data/lib/typhoeus/errors/typhoeus_error.rb +2 -0
  18. data/lib/typhoeus/errors.rb +4 -0
  19. data/lib/typhoeus/expectation.rb +33 -1
  20. data/lib/typhoeus/hydra/queueable.rb +29 -4
  21. data/lib/typhoeus/hydra.rb +349 -21
  22. data/lib/typhoeus/pool.rb +80 -17
  23. data/lib/typhoeus/railtie.rb +4 -2
  24. data/lib/typhoeus/request/actions.rb +2 -0
  25. data/lib/typhoeus/request/callbacks.rb +11 -4
  26. data/lib/typhoeus/request/marshal.rb +5 -2
  27. data/lib/typhoeus/request/streamable.rb +2 -0
  28. data/lib/typhoeus/request.rb +317 -30
  29. data/lib/typhoeus/response/cacheable.rb +2 -0
  30. data/lib/typhoeus/response/header.rb +234 -14
  31. data/lib/typhoeus/response/informations.rb +75 -12
  32. data/lib/typhoeus/response/status.rb +4 -13
  33. data/lib/typhoeus/response.rb +35 -0
  34. data/lib/typhoeus/version.rb +3 -1
  35. data/lib/typhoeus.rb +89 -26
  36. data/typhoeus.gemspec +15 -3
  37. metadata +19 -22
  38. data/lib/typhoeus/hydra/addable.rb +0 -23
  39. data/lib/typhoeus/hydra/before.rb +0 -31
  40. data/lib/typhoeus/hydra/block_connection.rb +0 -35
  41. data/lib/typhoeus/hydra/cacheable.rb +0 -15
  42. data/lib/typhoeus/hydra/memoizable.rb +0 -56
  43. data/lib/typhoeus/hydra/runnable.rb +0 -19
  44. data/lib/typhoeus/hydra/stubbable.rb +0 -28
  45. data/lib/typhoeus/request/before.rb +0 -30
  46. data/lib/typhoeus/request/block_connection.rb +0 -52
  47. data/lib/typhoeus/request/cacheable.rb +0 -38
  48. data/lib/typhoeus/request/memoizable.rb +0 -38
  49. data/lib/typhoeus/request/operations.rb +0 -40
  50. data/lib/typhoeus/request/responseable.rb +0 -29
  51. data/lib/typhoeus/request/stubbable.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da76288cb44cae7a0b697d2758d41c736ce8cd35b83cc80dcc36b05a46b71601
4
- data.tar.gz: 00675ad1b7cca1fa8a944c03450d1ff78419df4a734913f9297f00fb890bed41
3
+ metadata.gz: 1abf8466633716b18bb0ef19539ce79aaa9bf56930494541a9372a0c764ed50d
4
+ data.tar.gz: f3a18a7d60b34d00e9a14534046bb5e3742cbb603139784953e9ec280c099768
5
5
  SHA512:
6
- metadata.gz: 931cc5e229d88380754841384cd11aa2e96f851d7ba765420f00e9817d2e05be0b77fbd96d68c21865fd894f34d5708f5c2d306fa0cc9bdbf3c06489103b0b0e
7
- data.tar.gz: 8b26b43c59ef011e401f6938ba063fceea42288e755f4762a08b5cf44f6d82dbe8f30959ea65a446a73da35127378d2a2e24f6e920fbe067fcaa37f01320cbe5
6
+ metadata.gz: 5bb053e19b4651a62653f06d7bccd54c53cfd9cc6b5d78da2e3a61cd0b3512996bec52a57c15876b1ab2dc3ce788a7dc56a33c3843366f3d1a9c5a22188654d6
7
+ data.tar.gz: fadc8d26c5cf28638efd58580062dc8831df67ba886ddccb6adc49a9cd4dcd52141e587f4c71044104cfac68f8897ecb465064e21aa03152fb93bb83c0346c61
data/CHANGELOG.md CHANGED
@@ -2,7 +2,234 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.6.0...master)
5
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.7.1...master)
6
+
7
+ ## 1.7.1
8
+
9
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.7.0...v1.7.1)
10
+
11
+ * Require Ethon >= 0.19.1. Ethon 0.19.0 rejects `Easy#cleanup` from an
12
+ `on_complete` callback, which broke every request with `:resolve` because
13
+ Typhoeus cleans up resolve-list easies instead of pooling them. The
14
+ compatibility specs now cover a `:resolve` request.
15
+ ([#824](https://github.com/typhoeus/typhoeus/issues/824),
16
+ [ethon#456](https://github.com/typhoeus/ethon/pull/456))
17
+
18
+ ## 1.7.0
19
+
20
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.6.0...v1.7.0)
21
+
22
+ This release requires Ethon 0.19 and changes several public behaviors.
23
+ Review the breaking changes and `UPGRADE.md` before upgrading.
24
+
25
+ ### Breaking changes
26
+
27
+ * Require Ethon >= 0.19.0. Release easy handles when callbacks raise, clean up
28
+ failed hydra runs without dropping queued requests, drop inherited handles
29
+ after fork, and document fork and empty-header behavior. Ethon 0.19 also
30
+ propagates callback exceptions, rejects handles inherited across `fork`,
31
+ validates enum and bitmask options, and fixes multipart PUT requests.
32
+ * Constrain the Ethon dependency to `< 0.20` so a future pre-1.0 minor
33
+ release cannot introduce breaking changes unnoticed.
34
+ * Call `on_progress` callbacks with the documented four arguments. A lambda
35
+ with four parameters no longer raises `ArgumentError`.
36
+ * Raise `ArgumentError` for a non-positive `Hydra` `max_concurrency`, including
37
+ when it is assigned after the hydra is created, instead of leaving every
38
+ queued request unperformed.
39
+ ([#753](https://github.com/typhoeus/typhoeus/pull/753))
40
+ * Raise `ArgumentError` with the option name for non-numeric timeout options
41
+ instead of failing with `NoMethodError` inside option sanitization.
42
+ ([#758](https://github.com/typhoeus/typhoeus/pull/758))
43
+ * Raise `Typhoeus::Errors::NoResponse` when a stub has no response or its
44
+ response block returns `nil` or a non-`Response` object.
45
+ ([#776](https://github.com/typhoeus/typhoeus/pull/776))
46
+
47
+ ### Behavior changes
48
+
49
+ * Make `Typhoeus.with_connection` thread-local so it no longer unblocks
50
+ requests in other threads.
51
+ ([#813](https://github.com/typhoeus/typhoeus/pull/813))
52
+ * Make `Typhoeus.with_connection` apply across fibers in the current thread
53
+ by using thread variables instead of fiber-local storage.
54
+ * Bypass stubs inside `Typhoeus.with_connection`. A stub can now forward its
55
+ request to the real service without matching itself in an endless loop, and
56
+ the real response is not finished a second time.
57
+ ([#809](https://github.com/typhoeus/typhoeus/pull/809))
58
+ * Return the response from a `before` callback that short-circuits a request
59
+ instead of returning `nil`.
60
+ ([#748](https://github.com/typhoeus/typhoeus/pull/748))
61
+ * Mark responses returned by `before` callbacks as mock responses. They are no
62
+ longer cached, and `success?` works for them.
63
+ * Finish every request that reuses a stubbed `Response` instead of treating the
64
+ response as already handled.
65
+ * Keep queued requests when a hydra run fails after reaching the multi, so a
66
+ caller can retry them after handling the error.
67
+ * Create a Hydra's native multi handle on first use. Creating or memoizing a
68
+ hydra during boot no longer initializes libcurl, which Ethon 0.19 rejects in
69
+ a forked child.
70
+ ([#790](https://github.com/typhoeus/typhoeus/pull/790))
71
+ * Do not create a Hydra's native multi handle when every queued request is
72
+ answered by a `before` callback, a stub, or the cache.
73
+ ([#802](https://github.com/typhoeus/typhoeus/pull/802))
74
+ * Only invoke `on_progress` callbacks while libcurl transfers data. They are no
75
+ longer called with a `Response` when the request completes, and global
76
+ `Typhoeus.on_progress` callbacks now run during the transfer as well.
77
+ ([#750](https://github.com/typhoeus/typhoeus/pull/750))
78
+ * Only cache complete, successful, non-mock responses and replay `on_headers`
79
+ and `on_body` callbacks for cache hits.
80
+ ([#763](https://github.com/typhoeus/typhoeus/pull/763))
81
+ * Exclude `cache_ttl` from `Request#cache_key`. Changing the TTL no longer
82
+ misses responses cached by an equivalent request with a different TTL.
83
+ ([#751](https://github.com/typhoeus/typhoeus/pull/751))
84
+ * Make `Request#cache_key` unambiguous for values that stringify the same, and
85
+ return a libcurl error instead of raising for an empty URL with params.
86
+ ([#768](https://github.com/typhoeus/typhoeus/pull/768))
87
+ * Normalize the request method and URL for cache keys, equality, and
88
+ memoization. `Typhoeus.get`, an implicit GET, `method: "GET"`, and a URI base
89
+ URL now refer to the same request.
90
+ ([#789](https://github.com/typhoeus/typhoeus/pull/789))
91
+ * Apply `timeout_ms` and `connecttimeout_ms` after their second-based options,
92
+ so an explicit millisecond timeout is no longer overridden by `timeout` or
93
+ `Typhoeus::Config.timeout`.
94
+ ([#788](https://github.com/typhoeus/typhoeus/pull/788))
95
+ * Merge the default `User-Agent` and `Expect` headers case-insensitively. A
96
+ caller using a lowercase header name no longer sends a duplicate value.
97
+ ([#784](https://github.com/typhoeus/typhoeus/pull/784))
98
+ * Run `on_headers` callbacks for memoized followers, disable memoization for
99
+ streaming requests whose body is not retained, and set `request.hydra` when a
100
+ request is added directly.
101
+ ([#774](https://github.com/typhoeus/typhoeus/pull/774))
102
+
103
+ ### Enhancements
104
+
105
+ * Use `SSL_CERT_FILE` and `SSL_CERT_DIR` as the default `cainfo` and `capath`
106
+ when the request does not set them.
107
+ * Unroll the include chains in `Hydra#add`/`Hydra#run` and
108
+ `Request#run`/`Request#response=`. The ordering of the before, stub, block
109
+ connection, cache, memoization, and transfer checks is now explicit.
110
+ `Typhoeus::Config.exclude_features = [:before]` skips before callbacks for
111
+ every request, and `bundle exec rake perf` benchmarks the request hot path.
112
+ ([#815](https://github.com/typhoeus/typhoeus/pull/815))
113
+ * Bound the easy pool with `Typhoeus::Config.max_idle_easies` (20 by default)
114
+ and replace the pool mutex after a fork instead of deadlocking on the
115
+ inherited lock.
116
+ ([#761](https://github.com/typhoeus/typhoeus/pull/761))
117
+ * Honor Faraday `verify_hostname` and SSL version options, and preserve the
118
+ response reason phrase.
119
+ ([#766](https://github.com/typhoeus/typhoeus/pull/766))
120
+ * Honor Faraday's `read_timeout` in the Typhoeus adapter, falling back to the
121
+ general `timeout` when it is not set.
122
+ ([#798](https://github.com/typhoeus/typhoeus/pull/798))
123
+ * Let `Expect: nil` opt out of Typhoeus's empty `Expect` header, so libcurl
124
+ decides when to send `100-continue`.
125
+ ([#808](https://github.com/typhoeus/typhoeus/pull/808))
126
+
127
+ ### Fixes and hardening
128
+
129
+ * Don't marshal per-request `before` callbacks. Requests with a `before`
130
+ callback can be dumped again.
131
+ ([#749](https://github.com/typhoeus/typhoeus/pull/749))
132
+ * Release the easy handle when installing response callbacks fails.
133
+ ([#752](https://github.com/typhoeus/typhoeus/pull/752))
134
+ * Build the synthetic status line for mocked responses from `response_code`/
135
+ `code`. It previously used the libcurl `return_code` symbol.
136
+ ([#754](https://github.com/typhoeus/typhoeus/pull/754))
137
+ * Replace the hydra's multi handle after a fatal `curl_multi_perform` error so
138
+ the hydra can run requests again.
139
+ ([#759](https://github.com/typhoeus/typhoeus/pull/759))
140
+ * Load the Rack middleware and the cache adapters independent of require order.
141
+ ([#760](https://github.com/typhoeus/typhoeus/pull/760))
142
+ * Drain short-circuited hydra requests iteratively and finish the request when
143
+ a `before` callback returns a `Response`.
144
+ ([#762](https://github.com/typhoeus/typhoeus/pull/762))
145
+ * Keep callback results and per-request response objects intact when requests
146
+ are memoized, and clear stale memoization between runs.
147
+ ([#764](https://github.com/typhoeus/typhoeus/pull/764))
148
+ * Ignore HTTP/1.1 trailer blocks when parsing response headers and keep
149
+ `Response::Header` mutations in sync with case-insensitive reads.
150
+ ([#765](https://github.com/typhoeus/typhoeus/pull/765))
151
+ * Decode parameters for hash-like objects such as
152
+ `ActionController::Parameters`, deep-copy in `decode`, and register the Rack
153
+ middleware class in the Railtie.
154
+ ([#767](https://github.com/typhoeus/typhoeus/pull/767))
155
+ * Raise `Ethon::Errors::InvalidOption` with a clean message for removed and
156
+ replaced options instead of wrapping the error message as the option name.
157
+ ([#770](https://github.com/typhoeus/typhoeus/pull/770))
158
+ * Build `Request#url` from the URL-related options only, so unrelated invalid
159
+ options do not break it, and fall back to the base URL in `NoStub` when the
160
+ full URL cannot be built.
161
+ ([#771](https://github.com/typhoeus/typhoeus/pull/771))
162
+ * Make duplicated responses independent. Memoized followers no longer share
163
+ options, headers, body strings, or the leader's `handled_response`, and
164
+ `Header.new(header)` preserves its values.
165
+ ([#772](https://github.com/typhoeus/typhoeus/pull/772))
166
+ * Keep `Response::Header` case-insensitive lookups in sync after `delete_if`,
167
+ `select!`, `keep_if`, `reject!`, `shift`, `compact!`, and `transform_*!`.
168
+ ([#773](https://github.com/typhoeus/typhoeus/pull/773))
169
+ * Make `Request#encoded_body` match the form sent on the wire, including
170
+ `params_encoding` and escaping.
171
+ ([#775](https://github.com/typhoeus/typhoeus/pull/775))
172
+ * Keep pooling easy handles when libcurl was built without cookie support, and
173
+ validate `Typhoeus::Config.max_idle_easies` when it is assigned.
174
+ ([#777](https://github.com/typhoeus/typhoeus/pull/777))
175
+ * Read Rails cache entries with the same cache key that was written.
176
+ ([#778](https://github.com/typhoeus/typhoeus/pull/778))
177
+ * Deliver an independent response for cache hits so `on_headers` callbacks and
178
+ `handled_response` from an earlier request do not leak into the cached object.
179
+ ([#781](https://github.com/typhoeus/typhoeus/pull/781))
180
+ * Finish memoized followers when a completion callback changes the leader's
181
+ options before the memoization bookkeeping runs.
182
+ ([#782](https://github.com/typhoeus/typhoeus/pull/782))
183
+ * Clean up the native easy handles when `Typhoeus::Pool.clear` empties the pool
184
+ instead of leaking them.
185
+ ([#783](https://github.com/typhoeus/typhoeus/pull/783))
186
+ * Include the replacement or removal hint in every rendering of
187
+ `Typhoeus::Errors::InvalidOption`, not only in `#message`.
188
+ ([#785](https://github.com/typhoeus/typhoeus/pull/785))
189
+ * Copy arrays in the Rack params decoder and decode encoded hashes nested in
190
+ arrays.
191
+ ([#786](https://github.com/typhoeus/typhoeus/pull/786))
192
+ * Build `Request#encoded_body` with Ethon's request action so PUT escaping
193
+ matches POST.
194
+ ([#787](https://github.com/typhoeus/typhoeus/pull/787))
195
+ * Store a snapshot of a response before caching it or using it as the
196
+ memoization leader. Mutating a response after a request no longer changes
197
+ later cache hits, and a leader's callbacks no longer change a follower's
198
+ response.
199
+ ([#797](https://github.com/typhoeus/typhoeus/pull/797))
200
+ * Exclude the response from `Request#marshal_dump`. Completed requests whose
201
+ callbacks return non-marshalable values can be dumped again.
202
+ ([#799](https://github.com/typhoeus/typhoeus/pull/799))
203
+ * Make `Response::Header#merge`, `#fetch`, and `#fetch_values` follow the
204
+ same case-insensitive, string-key semantics as the rest of the header API.
205
+ ([#800](https://github.com/typhoeus/typhoeus/pull/800))
206
+ * Copy string and array header values when a `Response::Header` is built from
207
+ a hash, so mutating the response cannot change the caller's hash.
208
+ ([#801](https://github.com/typhoeus/typhoeus/pull/801))
209
+ * Decode query and form parameters independently in the Rack middleware. A
210
+ form value no longer overwrites the query value for the same key.
211
+ ([#803](https://github.com/typhoeus/typhoeus/pull/803))
212
+ * Rewind seekable upload bodies before measuring them, so an IO that was
213
+ already read from no longer fails with `:read_error`.
214
+ ([#804](https://github.com/typhoeus/typhoeus/pull/804))
215
+ * Parse `Response#response_code` from the status line when a response was
216
+ built from raw headers, such as the responses returned by
217
+ `Response#redirections`.
218
+ ([#805](https://github.com/typhoeus/typhoeus/pull/805))
219
+
220
+ ### Documentation and maintenance
221
+
222
+ * Build the gem from a source tarball or a working tree without git instead
223
+ of producing an empty package.
224
+ * Move the test dependencies to Sinatra 3, Rack 2.2, Dalli 3, and Redis 5.
225
+ This also makes the Ethon master workflow pass with frozen string literals.
226
+ ([#779](https://github.com/typhoeus/typhoeus/pull/779))
227
+ * Document initializing libcurl before forking on macOS to avoid
228
+ `objc_initializeAfterForkError`.
229
+ ([#810](https://github.com/typhoeus/typhoeus/pull/810))
230
+ * Add integration coverage for Faraday adapter timeouts, including
231
+ `read_timeout` precedence.
232
+ ([#811](https://github.com/typhoeus/typhoeus/pull/811))
6
233
 
7
234
  ## 1.6.0
8
235