diff --git a/lib/mint/http.ex b/lib/mint/http.ex index d0009662..6b4ac4b1 100644 --- a/lib/mint/http.ex +++ b/lib/mint/http.ex @@ -939,7 +939,7 @@ defmodule Mint.HTTP do body: binary() } def request_and_response(conn, method, path, headers, body, options \\ []) do - options = Keyword.validate!(options, timeout: :infinity) + options = keyword_validate!(options, timeout: :infinity) with {:ok, conn, ref} <- request(conn, method, path, headers, body) do recv_response(conn, ref, options[:timeout]) @@ -1008,6 +1008,13 @@ defmodule Mint.HTTP do end end + # TODO: Remove when we require Elixir v1.13 + if Version.match?(System.version(), ">= 1.13") do + defp keyword_validate!(keyword, values), do: Keyword.validate!(keyword, validate) + else + defp keyword_validate!(keyword, _values), do: keyword + end + @doc """ Changes the mode of the underlying socket.