1

I am working on Elixir, using Erlang built-in :httpc function to perform a get request.

if {:ok, {status, header, body}} = :httpc.request(:get, {img, []}, [], []) do
  # ...
end

The functions are working well. Then after running mix dialyzer, it returns errors:

:0:unknown_function
Function :httpc.request/4 does not exist.
________________________________________________________________________________
lib/vutuv/accounts.ex:301:guard_fail
Guard test:
_ :: {:ok, {_, _, _}}

===

false

can never succeed.
________________________________________________________________________________
done (warnings were emitted)

I put this line to tell Dialyzer to skip checking the function.

@dialyzer {:nowarn_function, get_gravatar: 2}

However, the error still persists

:0:unknown_function
Function :httpc.request/4 does not exist.
________________________________________________________________________________
done (warnings were emitted)
Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Hendri Tobing
  • 351
  • 5
  • 14

1 Answers1

0

This is solved in https://elixirforum.com/t/dialyzer-does-not-know-httpc/21622/3

After adding :inets to the extra_applications in mix.exs, everything is passed successfully.

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Hendri Tobing
  • 351
  • 5
  • 14
  • Unrelated but important: :httpc doesn't do https (well it does, but not automatically and it's hard to get it right even for security experts) so be careful should you need either authentication, integrity or confidentiality when doing requests. – Tangui Apr 14 '19 at 07:49