如何使用Erlang进行HTTPS请求?

时间:2010-05-22 01:05:44

标签: ssl https erlang otp inets

我尝试了inets库,但它超时了。我不认为它支持HTTPS。我正在尝试使用ibrowse,但它无法正常工作。

2 个答案:

答案 0 :(得分:29)

这对我来说很好用:

1> application:start(inets).
ok
2> application:start(ssl).  
ok
3> http:request(head, {"https://example.com", []}, [{ssl,[{verify,0}]}], []).
{ok,{{"HTTP/1.1",200,"OK"},
     [{"cache-control","max-age=0, proxy-revalidate"},
      {"date","Sun, 23 May 2010 00:38:33 GMT"},
      {"server","BAIDA/1.0.0"},
      {"content-type","text/html; charset=windows-1251"},
      {"expires","Sun, 23 May 2010 00:38:33 GMT"},
      {"set-cookie",
       "uid=9041986921274575113; domain=.example.com; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT"}],
     []}}

http:request("https://example.com")也可以使用,您只需在任何请求之前加载适当的应用程序。

答案 1 :(得分:0)

这对我有用:

application:start(crypto),
application:start(public_key),
application:start(ssl),
application:start(inets).

httpc:request(head, {"https://example.com", []}, [{ssl,[{verify,0}]}], []).