Skip to content

Commit

Permalink
Added test case and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagopromano authored and yordis committed Dec 3, 2022
1 parent 158b24a commit 88c5286
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tesla/adapter/hackney.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if Code.ensure_loaded?(:hackney) do
adapter Tesla.Adapter.Hackney
end
```
## Adapter specific options
- `:max_body` - Max response body size in bytes. Actual response may be bigger because hackney stops after the last chunk that surpasses `:max_body`.
"""
@behaviour Tesla.Adapter
alias Tesla.Multipart
Expand Down
12 changes: 12 additions & 0 deletions test/tesla/adapter/hackney_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ defmodule Tesla.Adapter.HackneyTest do
assert is_reference(response.body) == true
end

test "get with `:max_body` option" do
request = %Env{
method: :post,
url: "#{@http}/post",
body: String.duplicate("long response", 1000)
}

assert {:ok, %Env{} = response} = call(request, with_body: true, max_body: 100)
assert response.status == 200
assert byte_size(response.body) < 2000
end

test "request timeout error" do
request = %Env{
method: :get,
Expand Down

0 comments on commit 88c5286

Please sign in to comment.