Compare commits

...

3 Commits

Author SHA1 Message Date
Matt
3409c91abb
Merge branch 'main' into new-docs 2023-07-13 15:24:07 +01:00
Mattia Giuffrida
9ca049ec77 Address additional code review comments 2023-07-13 13:34:36 +01:00
Olle Jonsson
15788115f5
Refer to correct branch [ci skip] (#1516) 2023-07-10 12:52:09 +01:00
4 changed files with 10 additions and 8 deletions

View File

@ -47,6 +47,6 @@ But before you start coding, please read our [Contributing Guide][contributing]
[awesome]: https://github.com/lostisland/awesome-faraday/#adapters
[website]: https://lostisland.github.io/faraday
[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
[actions]: https://github.com/lostisland/faraday/actions

View File

@ -64,7 +64,7 @@ conn.get('/stream/100') do |req|
# Set a callback which will receive tuples of chunk Strings,
# 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.
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"
streamed << chunk
end

View File

@ -48,13 +48,13 @@ end
| 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. |
| `: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. |
| `: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
[parallel]: /adapters/custom/parallel-requests.md

View File

@ -25,7 +25,8 @@ puts "Time taken: #{Time.now - now}"
## A note on Async
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:
```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.
[Async]: https://github.com/socketry/async
[async-http-faraday]: https://github.com/socketry/async-http-faraday