Skip to content

Commit

Permalink
Fix typespec for put_header (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
moogle19 authored Oct 27, 2023
1 parent 2b637db commit d21ab7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/req/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,15 @@ defmodule Req.Request do
["application/json"]
"""
@spec put_header(t(), binary(), binary()) :: t()
if Req.MixProject.legacy_headers_as_lists?() do
@spec put_header(t(), binary(), binary()) :: t()
def put_header(%Req.Request{} = request, name, value)
when is_binary(name) and is_binary(value) do
name = Req.__ensure_header_downcase__(name)
%{request | headers: List.keystore(request.headers, name, 0, {name, value})}
end
else
@spec put_header(t(), binary(), binary() | [binary()]) :: t()
def put_header(%Req.Request{} = request, name, value)
when is_binary(name) and (is_binary(value) or is_list(value)) do
name = Req.__ensure_header_downcase__(name)
Expand Down

0 comments on commit d21ab7f

Please sign in to comment.