CI (#2) Handle redirect to S3 asset manually
diff --git a/lib/dart_sass.ex b/lib/dart_sass.ex
index 4c4d5b3..6e4d158 100644
--- a/lib/dart_sass.ex
+++ b/lib/dart_sass.ex
@@ -257,6 +257,7 @@ defmodule DartSass do
cacertfile = CAStore.file_path() |> String.to_charlist()
http_options = [
+ autoredirect: false,
ssl: [
verify: :verify_peer,
cacertfile: cacertfile,
@@ -267,11 +268,18 @@ defmodule DartSass do
]
]
- options = [body_format: :binary]
+ case :httpc.request(:get, {url, []}, http_options, []) do
+ {:ok, {{_, 302, _}, headers, _}} ->
+ {'location', download} = List.keyfind(headers, 'location', 0)
+ options = [body_format: :binary]
- case :httpc.request(:get, {url, []}, http_options, options) do
- {:ok, {{_, 200, _}, _headers, body}} ->
- body
+ case :httpc.request(:get, {download, []}, http_options, options) do
+ {:ok, {{_, 200, _}, _, body}} ->
+ body
+
+ other ->
+ raise "couldn't fetch #{download}: #{inspect(other)}"
+ end
other ->
raise "couldn't fetch #{url}: #{inspect(other)}"