In Erlang -- HTTP Client, if I follow the instructions (without using a proxy because I don’t need a proxy here), erl hangs when making a request to http://www.erlang.org.
johnk@dirtynewcomputer:~$ erl
Erlang/OTP 26 [erts-14.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Eshell V14.0 (press Ctrl+G to abort, type help(). for help)
1> inets:start().
ok
2> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} =
.. httpc:request(get, {"http://www.erlang.org", []}, [], []).
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a
That’s because after this documentation was written, http://www.erlang.org now redirects to https://www.erlang.org, which requires ssl:start().
e.g.
johnk@dirtynewcomputer:~$ erl
Erlang/OTP 26 [erts-14.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Eshell V14.0 (press Ctrl+G to abort, type help(). for help)
1> inets:start().
ok
2> ssl:start().
ok
3> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request(get, {"http://www.erlang.org", []}, [], []).
{ok,{{"HTTP/1.1",200,"OK"},
[{"cache-control","public,max-age=0,must-revalidate"},
{"date","Tue, 22 Aug 2023 22:21:43 GMT"},
{"accept-ranges","bytes"},
{"age","11450"},
{"etag","\"1050519f47cb36b79741a041558c101d-ssl\""},
{"server","Netlify"},
{"content-length","19144"},
{"content-type","text/html; charset=UTF-8"},
{"strict-transport-security","max-age=31536000"},
{"x-nf-request-id","01H8FNDT5CBS2Q7GZNXX92MD59"}],
"<!DOCTYPE html>\n<html lang=\"en\">\n\n\n\n<head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\n
...
Given that these days, more and more sites are moving to https-only mode, and redirecting http to https (like www.erlang.org does) should inets:start()
actually include ssl:start().
or equivalent? Or just update the documentation for inets?
Thanks,
- johnk