Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed underspecced request functions #401

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions lib/httpoison/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,26 @@ defmodule HTTPoison.Base do
@callback put!(url, body, headers) :: Response.t() | AsyncResponse.t()
@callback put!(url, body, headers, options) :: Response.t() | AsyncResponse.t()

@callback request(atom, url) :: {:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
@callback request(atom, url, body) ::
@callback request(method, url) :: {:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
@callback request(method, url, body) ::
{:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
@callback request(atom, url, body, headers) ::
@callback request(method, url, body, headers) ::
{:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
@callback request(atom, url, body, headers, options) ::
@callback request(method, url, body, headers, options) ::
{:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}

@callback request!(atom, url) :: Response.t() | AsyncResponse.t()
@callback request!(atom, url, body) :: Response.t() | AsyncResponse.t()
@callback request!(atom, url, body, headers) :: Response.t() | AsyncResponse.t()
@callback request!(atom, url, body, headers, options) :: Response.t() | AsyncResponse.t()
@callback request!(method, url) :: Response.t() | AsyncResponse.t()
@callback request!(method, url, body) :: Response.t() | AsyncResponse.t()
@callback request!(method, url, body, headers) :: Response.t() | AsyncResponse.t()
@callback request!(method, url, body, headers, options) :: Response.t() | AsyncResponse.t()

@callback start() :: {:ok, [atom]} | {:error, term}

@callback stream_next(AsyncResponse.t()) :: {:ok, AsyncResponse.t()} | {:error, Error.t()}

@type response :: Response.t()
@type request :: Request.t()
@type method :: Request.method()
@type url :: Request.url()
@type headers :: Request.headers()
@type body :: Request.body()
Expand All @@ -204,6 +205,7 @@ defmodule HTTPoison.Base do
@behaviour HTTPoison.Base

@type request :: HTTPoison.Base.request()
@type method :: HTTPoison.Base.method()
@type url :: HTTPoison.Base.url()
@type headers :: HTTPoison.Base.headers()
@type body :: HTTPoison.Base.body()
Expand Down Expand Up @@ -352,7 +354,7 @@ defmodule HTTPoison.Base do
request(:post, "https://my.website.com", "{\"foo\": 3}", [{"Accept", "application/json"}])

"""
@spec request(atom, binary, any, headers, Keyword.t()) ::
@spec request(method, binary, any, headers, Keyword.t()) ::
{:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
def request(method, url, body \\ "", headers \\ [], options \\ []) do
request(%Request{
Expand All @@ -372,7 +374,8 @@ defmodule HTTPoison.Base do
response in case of a successful request, raising an exception in case the
request fails.
"""
@spec request!(atom, binary, any, headers, Keyword.t()) :: Response.t() | AsyncResponse.t()
@spec request!(method, binary, any, headers, Keyword.t()) ::
Response.t() | AsyncResponse.t()
def request!(method, url, body \\ "", headers \\ [], options \\ []) do
case request(method, url, body, headers, options) do
{:ok, response} -> response
Expand Down Expand Up @@ -777,7 +780,7 @@ defmodule HTTPoison.Base do
end

@doc false
@spec request(atom, request, fun, fun, fun, fun) ::
@spec request(module, request, fun, fun, fun, fun) ::
{:ok, Response.t() | AsyncResponse.t()} | {:error, Error.t()}
def request(
module,
Expand Down
11 changes: 5 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ defmodule HTTPoison.Mixfile do
dialyzer: [
plt_add_deps: :transitive,
flags: [
# "-Wunmatched_returns",
# "-Wrace_conditions",
# "-Wunderspecs",
# "-Wunknown",
# "-Woverspecs",
# "-Wspecdiffs",
:unmatched_returns,
:race_conditions,
:underspecs
# :overspecs,
# :specdiffs
]
]
]
Expand Down