Pro Yearly is on sale from $80 to $50! »

Mint - Disrupting HTTP clients

Mint - Disrupting HTTP clients

Faafc04d9e69b73b9f49995fd4c94d4d?s=128

Andrea Leopardi

August 29, 2019
Tweet

Transcript

  1. None
  2. None
  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. {:ok, conn} = Mint.HTTP.connect( :https, "example.com", 80 ) conn #=>

    %Mint.HTTP1{...}
  17. {:ok, conn, request_ref} = Mint.HTTP.request( conn, "GET", "/", [{"content-type", "text/html"}]

    )
  18. None
  19. {:ok, conn, request_ref} = Mint.HTTP.request(...)

  20. None
  21. None
  22. None
  23. receive do message -> Mint.HTTP.stream(conn, message) end

  24. case Mint.HTTP.stream(conn, message) do :unknown -> # ... {:ok, conn,

    responses} -> # ... {:error, conn, reason, responses} -> # ... end
  25. {:status, ref, 200} {:headers, ref, [...]} {:data, ref, "...chunk..."} {:done,

    ref} {:error, ref, reason}
  26. None
  27. None
  28. None
  29. :inets.start() :ssl.start() :httpc.request( 'https://self-signed.badssl.com' ) #=> {:ok, {{'HTTP/1.1', 200, 'OK'}...}

  30. :hackney.request( :get, "https://self-signed.badssl.com", _headers = [], _body = "", _opts

    = [] ) #=> {:error, {:tls_alert, ...}}
  31. :hackney.request( :get, "https://self-signed.badssl.com", _headers = [], _body = "", ssl_options:

    [versions: [:"tlsv1.2"]] ) #=> {:ok, 200, ...}
  32. Mint.HTTP.connect( :https, "https://self-signed.badssl.com", 443 ) #=> {:error, %Mint.TransportError{...}}

  33. None
  34. None
  35. defp deps do [ # ..., {:mint, "~> 0.4"}, {:castore,

    "~> 0.1"} ] end
  36. None
  37. None
  38. proxy = { :http, "proxy.example.com", 80, _opts = [] }

    Mint.HTTP.connect( :https, "httpbin.org", 443, proxy: proxy )
  39. None
  40. None
  41. None
  42. None
  43. None
  44. { :push_promise, ref, promised_ref, promised_headers }

  45. None
  46. {:ok, conn, ref} = Mint.HTTP2.ping(conn) # ... response #=> {:pong,

    ^ref}
  47. None
  48. Mint.HTTP.connect(...) Mint.HTTP1.connect(...) Mint.HTTP2.connect(...)

  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None