Skip to content

Commit

Permalink
filter out req user agents
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschweikert committed Dec 30, 2024
1 parent 3d2ec14 commit 620045d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/curl_req/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ defmodule CurlReq.Request do
@spec put_redirect(__MODULE__.t(), :req | :curl | String.t()) :: __MODULE__.t()
def put_user_agent(%__MODULE{} = request, nil), do: request

def put_user_agent(%__MODULE{} = request, "req/" <> _) do
%{request | user_agent: :req}
end

def put_user_agent(%__MODULE{} = request, user_agent)
when user_agent in [:curl, :req] or is_binary(user_agent) do
%{request | user_agent: user_agent}
Expand Down
4 changes: 0 additions & 4 deletions test/curl_req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ defmodule CurlReqTest do
assert ~CURL(curl -H "user-agent: req/0.4.14" -X GET https://example.com/fact) ==
%Req.Request{
method: :get,
headers: %{"user-agent" => ["req/0.4.14"]},
url: URI.parse("https://example.com/fact")
}
end
Expand All @@ -246,9 +245,6 @@ defmodule CurlReqTest do
%Req.Request{
method: :post,
url: URI.parse("https://example.com/rest/v1/leads/submitForm.json"),
headers: %{
"user-agent" => ["req/0.4.14"]
},
registered_options: MapSet.new([:compressed, :auth, :json]),
options: %{
compressed: true,
Expand Down

0 comments on commit 620045d

Please sign in to comment.