From 40eadf3c9b402fbb78185a4302e01ec75ab78717 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Thu, 16 Jan 2025 11:22:29 +0100 Subject: [PATCH] Clarify behavior of Mint.HTTP.stream/3 --- lib/mint/http.ex | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/mint/http.ex b/lib/mint/http.ex index bc4cb624..08560049 100644 --- a/lib/mint/http.ex +++ b/lib/mint/http.ex @@ -710,6 +710,14 @@ defmodule Mint.HTTP do where `conn` is the updated connection, `reason` is the error reason, and `responses` is a list of responses that were correctly parsed before the error. + > #### Graceful Close {: .tip} + > + > If this function returns `{:ok, conn, responses}`, it doesn't *necessarily* mean + > that the connection is still open. For example, TCP/SSL **close** messages are treated + > as errors only if there are in-flight requests. If there are no in-flight requests, + > the connection is closed gracefully and `{:ok, conn, responses}` is returned. + > Always check with `open?/1` to see if the connection is still open. + If the given `message` is not from the connection's socket, this function returns `:unknown`.