View Slide
{:ok, conn} =Mint.HTTP.connect(:https,"example.com",80)conn#=> %Mint.HTTP1{...}
{:ok, conn, request_ref} =Mint.HTTP.request(conn,"GET","/",[{"content-type", "text/html"}])
{:ok, conn, request_ref} =Mint.HTTP.request(...)
receive domessage ->Mint.HTTP.stream(conn, message)end
case Mint.HTTP.stream(conn, message) do:unknown -># ...{:ok, conn, responses} -># ...{:error, conn, reason, responses} -># ...end
{:status, ref, 200}{:headers, ref, [...]}{:data, ref, "...chunk..."}{:done, ref}{:error, ref, reason}
:inets.start():ssl.start():httpc.request('https://self-signed.badssl.com')#=> {:ok, {{'HTTP/1.1', 200, 'OK'}...}
:hackney.request(:get,"https://self-signed.badssl.com",_headers = [],_body = "",_opts = [])#=> {:error, {:tls_alert, ...}}
:hackney.request(:get,"https://self-signed.badssl.com",_headers = [],_body = "",ssl_options: [versions: [:"tlsv1.2"]])#=> {:ok, 200, ...}
Mint.HTTP.connect(:https,"https://self-signed.badssl.com",443)#=> {:error, %Mint.TransportError{...}}
defp deps do[# ...,{:mint, "~> 0.4"},{:castore, "~> 0.1"}]end
proxy = {:http,"proxy.example.com",80,_opts = []}Mint.HTTP.connect(:https,"httpbin.org",443,proxy: proxy)
{:push_promise,ref,promised_ref,promised_headers}
{:ok, conn, ref} =Mint.HTTP2.ping(conn)# ...response#=> {:pong, ^ref}
Mint.HTTP.connect(...)Mint.HTTP1.connect(...)Mint.HTTP2.connect(...)