Skip to content

Commit e1303cb

Browse files
authored
Merge pull request #122 from bitboxer/add_max_body_length
Added max_body_length to hackney options
2 parents 1c1e49b + 9c4695b commit e1303cb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/waffle/file.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ defmodule Waffle.File do
173173

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

216217
defp body(client_ref, response_headers) do
217-
case :hackney.body(client_ref) do
218+
max_body_length = Application.get_env(:waffle, :max_body_length, :infinity)
219+
220+
case :hackney.body(client_ref, max_body_length) do
218221
{:ok, body} ->
219222
response_headers = :hackney_headers.new(response_headers)
220223
filename = content_disposition(response_headers)

0 commit comments

Comments
 (0)