Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/elixir_make/downloader/httpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule ElixirMake.Downloader.Httpc do
] ++ cacerts_options()
]

options = [body_format: :binary]
options = [body_format: :binary, max_header_size: 65_536]

case :httpc.request(:get, {url_charlist, []}, https_options, options) do
{:ok, {{_, 200, _}, _headers, body}} ->
Expand Down
38 changes: 38 additions & 0 deletions test/elixir_make/downloader/httpc_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
defmodule ElixirMake.Downloader.HttpcTest do
use ExUnit.Case, async: true

alias ElixirMake.Downloader.Httpc

setup_all do
if function_exported?(Mix, :ensure_application!, 1) do
Mix.ensure_application!(:inets)
Mix.ensure_application!(:ssl)
Mix.ensure_application!(:crypto)
end

:ok
end

test "downloads a response whose headers exceed httpc's default limit" do
{:ok, listen} = :gen_tcp.listen(0, [:binary, active: false, reuseaddr: true])
{:ok, port} = :inet.port(listen)

# GitHub's release-download redirects send about 11 KB of headers.
padding = String.duplicate("a", 12_288)

Task.start_link(fn ->
{:ok, socket} = :gen_tcp.accept(listen)
{:ok, _request} = :gen_tcp.recv(socket, 0)

:ok =
:gen_tcp.send(
socket,
"HTTP/1.1 200 OK\r\nx-padding: #{padding}\r\ncontent-length: 3\r\nconnection: close\r\n\r\nnif"
)

:gen_tcp.close(socket)
end)

assert Httpc.download("http://127.0.0.1:#{port}/nif.tar.gz") == {:ok, "nif"}
end
end
Loading