Skip to content

Commit

Permalink
Merge pull request #122 from bitboxer/add_max_body_length
Browse files Browse the repository at this point in the history
Added max_body_length to hackney options
  • Loading branch information
achempion authored May 19, 2024
2 parents 1c1e49b + 9c4695b commit e1303cb
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit e1303cb

Please sign in to comment.