-
Notifications
You must be signed in to change notification settings - Fork 100
Closed
Description
We would like to inject additional headers depending on options. In particular we have the following extract from here
def process_request_headers(headers, options) do
case Keyword.get(options, :cookie) do
nil ->
headers
cookie ->
Keyword.put(headers, :Cookie, cookie)
end
end
Unfortunately in order to achieve that we have to override process_arguments/3 function. Which is quite complex.
I've noticed that recently the #128 was merged. Which modifies the signature of process_request_headers to support passing body.
Would it be possible to use similar approach and implement
def process_request_headers(headers, _body, _options), do: process_request_headers(headers)
@@ -146,7 +148,7 @@ defmodule HTTPotion.Base do
headers = Application.get_env(:httpotion, :default_headers, [])
|> Keyword.merge(Keyword.get(options, :headers, [])
|> Enum.map(fn ({k, v}) -> { (if is_atom(k), do: k, else: String.to_atom(to_string(k))), to_string(v) } end))
- |> process_request_headers(body)
+ |> process_request_headers(body, options)
Metadata
Metadata
Assignees
Labels
No labels