From e2ed4a9dcc2334f87b55e0c65d8adc082746cc91 Mon Sep 17 00:00:00 2001 From: eds314 <56859998+eds314@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:23:15 -0500 Subject: [PATCH] Rename follow redirect in Req adapter Closes #1087 --- lib/ex_aws/request/req.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ex_aws/request/req.ex b/lib/ex_aws/request/req.ex index b4a75b59..f63a3b57 100644 --- a/lib/ex_aws/request/req.ex +++ b/lib/ex_aws/request/req.ex @@ -16,6 +16,8 @@ defmodule ExAws.Request.Req do @impl true def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do + http_opts = rename_follow_redirect(http_opts) + [method: method, url: url, body: body, headers: headers, decode_body: false] |> Keyword.merge(Application.get_env(:ex_aws, :req_opts, @default_opts)) |> Keyword.merge(http_opts) @@ -28,4 +30,12 @@ defmodule ExAws.Request.Req do {:error, %{reason: reason}} end end + + # Req uses :follow_redirects, but some clients pass the :hackney option + # :follow_redirect. Rename the option for Req to use. + defp rename_follow_redirect(opts) do + {follow, opts} = Keyword.pop(opts, :follow_redirect, false) + + Keyword.put(opts, :follow_redirects, follow) + end end