Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- Accept up to 64 KiB of response headers when downloading NIF artifacts. GitHub release redirects now send more than the 10 KiB `:httpc` allows by default.

## 0.1.6 - 2026-09-10

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion lib/zigler_precompiled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ defmodule ZiglerPrecompiled do
Logger.debug("Downloading NIF from #{url}")

case :httpc.request(:get, {String.to_charlist(url), request_headers}, http_options,
body_format: :binary
body_format: :binary,
max_header_size: 65_536
) do
{:ok, {{_, 200, _}, _resp_headers, body}} ->
{:ok, body}
Expand Down
22 changes: 22 additions & 0 deletions test/download_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ defmodule ZiglerPrecompiled.DownloadTest do
assert result.checksum == "sha256:#{expected_hash}"
end

test "follows a redirect whose headers exceed httpc's default limit", %{bypass: bypass} do
Bypass.expect_once(bypass, "GET", "/download/my_nif.so.tar.gz", fn conn ->
conn
|> Plug.Conn.put_resp_header("content-security-policy", String.duplicate("a", 12 * 1024))
|> Plug.Conn.put_resp_header("location", "http://localhost:#{bypass.port}/artifact")
|> Plug.Conn.resp(302, "")
end)

Bypass.expect_once(bypass, "GET", "/artifact", fn conn ->
Plug.Conn.resp(conn, 200, "fake nif content")
end)

url = "http://localhost:#{bypass.port}/download/my_nif.so.tar.gz"

assert [%{path: path}] =
ZiglerPrecompiled.download_nif_artifacts_with_checksums!([
{"my_nif.so.tar.gz", {url, []}}
])

assert File.read!(path) == "fake nif content"
end

test "raises on failure without ignore flag", %{bypass: bypass} do
Bypass.expect(bypass, "GET", "/missing.so.tar.gz", fn conn ->
Plug.Conn.resp(conn, 404, "not found")
Expand Down