How do I do an HTTPS request with Erlang?

前端 未结 2 1694
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 14:47

I tried the inets library but it times out. I don\'t think it supports HTTPS. I am trying to use ibrowse, but it isn\'t working.

相关标签:
2条回答
  • 2020-12-28 15:41

    This works fine for me:

    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") would also work though, you just have to load appropriate applications before any request.

    0 讨论(0)
  • 2020-12-28 15:47

    This is what worked for me:

    application:start(crypto),
    application:start(public_key),
    application:start(ssl),
    application:start(inets).
    
    httpc:request(head, {"https://example.com", []}, [{ssl,[{verify,0}]}], []).
    
    0 讨论(0)
提交回复
热议问题