   end
 
   defp request(method, scheme, host, port, path, headers, body, opts) when is_function(body) do
-    with {:ok, conn} <- HTTP.connect(String.to_atom(scheme), host, port),
+    with {:ok, conn} <- HTTP.connect(String.to_atom(scheme), host, port, opts),
          # FIXME Stream function in Mint will not append the content length after eof
          # This will trigger the failure in unit test
          {:ok, body, length} <- stream_request(body),
-         {:ok, conn, req_ref} <- HTTP.request(conn, method, path || "/", headers ++ [{"content-length", "#{length}"}], body),
-         {:ok, _conn, res = %{status: status, headers: headers}} <- stream_response(conn)
-    do
+         {:ok, conn, _req_ref} <-
+           HTTP.request(
+             conn,
+             method,
+             path || "/",
+             headers ++ [{"content-length", "#{length}"}],
+             body
+           ),
+         {:ok, _conn, res = %{status: status, headers: headers}} <- stream_response(conn) do
       {:ok, status, headers, Map.get(res, :data)}
     end
   end
 
   defp request(method, scheme, host, port, path, headers, body, opts) do
-    with {:ok, conn} <- HTTP.connect(String.to_atom(scheme), host, port),
+    with {:ok, conn} <- HTTP.connect(String.to_atom(scheme), host, port, opts),
          {:ok, conn, _req_ref} <- HTTP.request(conn, method, path || "/", headers, body || ""),
          {:ok, _conn, res = %{status: status, headers: headers}} <- stream_response(conn) do
       {:ok, status, headers, Map.get(res, :data)}

      opts
    )
  end
  
  defp request(method, scheme, host, port, path, headers, %Stream{} = body, opts) do
    fun = stream_to_fun(body)
    request(method, scheme, host, port, path, headers, fun, opts)

    %URI{host: host, scheme: scheme, port: port, path: path, query: query} = URI.parse(env.url)
    query = (query || "") |> URI.decode_query() |> Map.to_list()
    path = Tesla.build_url(path, env.query ++ query)

    method =
      case env.method do
        :head -> "GET"
        m -> m |> Atom.to_string() |> String.upcase()
      end

    request(
      method,
