mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-14 00:03:03 -04:00
Compare commits
3 Commits
b7d4a548e1
...
3409c91abb
Author | SHA1 | Date | |
---|---|---|---|
|
3409c91abb | ||
|
9ca049ec77 | ||
|
15788115f5 |
@ -47,6 +47,6 @@ But before you start coding, please read our [Contributing Guide][contributing]
|
|||||||
[awesome]: https://github.com/lostisland/awesome-faraday/#adapters
|
[awesome]: https://github.com/lostisland/awesome-faraday/#adapters
|
||||||
[website]: https://lostisland.github.io/faraday
|
[website]: https://lostisland.github.io/faraday
|
||||||
[faraday_team]: https://lostisland.github.io/faraday/team
|
[faraday_team]: https://lostisland.github.io/faraday/team
|
||||||
[contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
|
[contributing]: https://github.com/lostisland/faraday/blob/main/.github/CONTRIBUTING.md
|
||||||
[apidoc]: https://www.rubydoc.info/github/lostisland/faraday
|
[apidoc]: https://www.rubydoc.info/github/lostisland/faraday
|
||||||
[actions]: https://github.com/lostisland/faraday/actions
|
[actions]: https://github.com/lostisland/faraday/actions
|
||||||
|
@ -64,7 +64,7 @@ conn.get('/stream/100') do |req|
|
|||||||
# Set a callback which will receive tuples of chunk Strings,
|
# Set a callback which will receive tuples of chunk Strings,
|
||||||
# the sum of characters received so far, and the response environment.
|
# the sum of characters received so far, and the response environment.
|
||||||
# The latter will allow access to the response status, headers and reason, as well as the request info.
|
# The latter will allow access to the response status, headers and reason, as well as the request info.
|
||||||
req.options.on_data = Proc.new do |chunk, overall_received_bytes, env|
|
req.options.on_data = proc do |chunk, overall_received_bytes, env|
|
||||||
puts "Received #{overall_received_bytes} characters"
|
puts "Received #{overall_received_bytes} characters"
|
||||||
streamed << chunk
|
streamed << chunk
|
||||||
end
|
end
|
||||||
|
@ -48,13 +48,13 @@ end
|
|||||||
|
|
||||||
| Feature | Description |
|
| Feature | Description |
|
||||||
|----------------------------------|----------------------------------------------------------------------------------------------------------|
|
|----------------------------------|----------------------------------------------------------------------------------------------------------|
|
||||||
| `:trace_method` | Tests your adapter against the `TRACE` HTTP method. |
|
|
||||||
| `:local_socket_binding` | Tests that your adapter supports binding to a local socket via the `:bind` request option. |
|
|
||||||
| `:request_body_on_query_methods` | Tests that your adapter supports sending a request body on `GET`, `HEAD`, `DELETE` and `TRACE` requests. |
|
|
||||||
| `:reason_phrase_parse` | Tests that your adapter supports parsing the `reason_phrase` from the response. |
|
|
||||||
| `:compression` | Tests that your adapter can handle `gzip` and `defalte` compressions. |
|
| `:compression` | Tests that your adapter can handle `gzip` and `defalte` compressions. |
|
||||||
| `:streaming` | Tests that your adapter supports streaming responses. See [Streaming][streaming] for more details. |
|
| `:local_socket_binding` | Tests that your adapter supports binding to a local socket via the `:bind` request option. |
|
||||||
| `:parallel` | Tests that your adapter supports parallel requests. See [Parallel requests][parallel] for more details. |
|
| `:parallel` | Tests that your adapter supports parallel requests. See [Parallel requests][parallel] for more details. |
|
||||||
|
| `:reason_phrase_parse` | Tests that your adapter supports parsing the `reason_phrase` from the response. |
|
||||||
|
| `:request_body_on_query_methods` | Tests that your adapter supports sending a request body on `GET`, `HEAD`, `DELETE` and `TRACE` requests. |
|
||||||
|
| `:streaming` | Tests that your adapter supports streaming responses. See [Streaming][streaming] for more details. |
|
||||||
|
| `:trace_method` | Tests your adapter against the `TRACE` HTTP method. |
|
||||||
|
|
||||||
[streaming]: /adapters/custom/streaming.md
|
[streaming]: /adapters/custom/streaming.md
|
||||||
[parallel]: /adapters/custom/parallel-requests.md
|
[parallel]: /adapters/custom/parallel-requests.md
|
||||||
|
@ -25,7 +25,8 @@ puts "Time taken: #{Time.now - now}"
|
|||||||
## A note on Async
|
## A note on Async
|
||||||
|
|
||||||
You might have heard about [Async] and its native integration with Ruby 3.0.
|
You might have heard about [Async] and its native integration with Ruby 3.0.
|
||||||
The good news is that you can already use Async with Faraday and this does not require the use of `#in_parallel` to run parallel requests.
|
The good news is that you can already use Async with Faraday (thanks to the [async-http-faraday] gem)
|
||||||
|
and this does not require the use of `#in_parallel` to run parallel requests.
|
||||||
Instead, you only need to wrap your Faraday code into an Async block:
|
Instead, you only need to wrap your Faraday code into an Async block:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@ -54,3 +55,4 @@ The big advantage of using Async is that you can now run parallel requests *span
|
|||||||
whereas the `#in_parallel` method only works for requests that are made through the same connection.
|
whereas the `#in_parallel` method only works for requests that are made through the same connection.
|
||||||
|
|
||||||
[Async]: https://github.com/socketry/async
|
[Async]: https://github.com/socketry/async
|
||||||
|
[async-http-faraday]: https://github.com/socketry/async-http-faraday
|
||||||
|
Loading…
x
Reference in New Issue
Block a user