diff --git a/lib/mint/http1.ex b/lib/mint/http1.ex index 941e12d0..fba50973 100644 --- a/lib/mint/http1.ex +++ b/lib/mint/http1.ex @@ -551,6 +551,7 @@ defmodule Mint.HTTP1 do case conn.transport.recv(conn.socket, byte_count, timeout) do {:ok, data} -> handle_data(conn, data) {:error, %Mint.TransportError{reason: :closed}} -> handle_close(conn) + {:error, %Mint.TransportError{reason: :timeout} = error} -> {:error, conn, error, []} {:error, error} -> handle_transport_error(conn, error) end end diff --git a/lib/mint/http2.ex b/lib/mint/http2.ex index d1b562d0..e6745900 100644 --- a/lib/mint/http2.ex +++ b/lib/mint/http2.ex @@ -874,6 +874,9 @@ defmodule Mint.HTTP2 do {:error, %TransportError{reason: :closed}} -> handle_closed(conn) + {:error, %TransportError{reason: :timeout} = error} -> + {:error, conn, error, []} + {:error, error} -> {:error, %{conn | state: :closed}, error, _responses = []} end