I am new to elixir and have no erlang (or func-y) experience, but this will soon become apparent .. →
iex(2)> :inets.start() :ok iex(3)> :httpc.request(["http://www.erlang.org"]) {:error, :no_scheme}
I have no idea what: no_scheme means. I have googled no_scheme and stuff, and I'm sure this is obvious, but I did not find anything. The only vague thing I could find in erlang docs was →
iex(4)> :http_uri.scheme_defaults [http: 80, https: 443, ftp: 21, ssh: 22, sftp: 22, tftp: 69]
or maybe I did not agree with RFC2616 or something like that ... I have no ideas (at the moment).
Elixir and Erlang are super super amazing, although any help in promoting my journey will be appreciated.
Thanks for any help!
I tried this in erl.
1> inets:start(). ok 2> httpc:request("http://www.erlang.org"). {ok,{{"HTTP/1.1",200,"OK"}, [{"date","Wed, 20 Nov 2013 23:15:45 GMT"}, {"server","inets/5.7.1"}, {"content-length","10385"}, {"content-type","text/html; charset=utf-8"}, {"set-cookie", " eptic_cookie=erlangorg@hades-3680318586833850369 ; path=/"}], "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE htm etc...
Edit:
Well, my biggest problem was that I quoted the lines "http://www.erlang.org" twice, and I think elixir -> erlang accepts them as single quoted ones, as parrotys answer 'http://www.erlang.org' .
no_scheme is still pretty cryptic. All I could find was related to RFC redirects and implementation. I just decided to consider this a common mistake, something related to the url.
Edit 2:
There is a blog post from someone that explains this well. Link
Erlang atoms, such as the database, become: the database, and a local variable, such as PgConn in the Erlang version, becomes pg_conn in Elixir.
We need single-quoted string literals when they are arguments to the Erlang function. If you have a UTF-8 string stored in an Elixir variable, you can convert it to a char list using the binary_to_list / 1 function.
Edit 3:
Ironically, the last last Elixir Sip called "HTTP Clients", which came out a few hours ago, covers my whole question. See which of you will meet this future!