Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added max_body_length to hackney options #122

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/waffle/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ defmodule Waffle.File do

# hackney :connect_timeout - timeout used when establishing a connection, in milliseconds
# hackney :recv_timeout - timeout used when receiving from a connection, in milliseconds
# hackney :max_body_length - maximum size of the file to download, in bytes. Defaults to :infinity
# :backoff_max - maximum backoff time, in milliseconds
# :backoff_factor - a backoff factor to apply between attempts, in milliseconds
defp get_remote_path(remote_path, definition) do
Expand Down Expand Up @@ -214,7 +215,9 @@ defmodule Waffle.File do
end

defp body(client_ref, response_headers) do
case :hackney.body(client_ref) do
max_body_length = Application.get_env(:waffle, :max_body_length, :infinity)

case :hackney.body(client_ref, max_body_length) do
{:ok, body} ->
response_headers = :hackney_headers.new(response_headers)
filename = content_disposition(response_headers)
Expand Down
Loading