File 0218-inets-improve-httpd-do-1-callback-docs-and-spec.patch of Package erlang
From af352b83a233528c7e05064e0d4580dfc2979207 Mon Sep 17 00:00:00 2001
From: Konrad Pietrzak <konrad@erlang.org>
Date: Wed, 28 Jan 2026 15:44:11 +0100
Subject: [PATCH] `inets` improve httpd `do/1` callback docs and spec
---
lib/inets/src/http_server/httpd.erl | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/inets/src/http_server/httpd.erl b/lib/inets/src/http_server/httpd.erl
index b467329afe..d3486a8e67 100644
--- a/lib/inets/src/http_server/httpd.erl
+++ b/lib/inets/src/http_server/httpd.erl
@@ -865,17 +865,29 @@ that the fun either returns a list `(Body)` that is an HTTP response, or the
atom `sent` if the HTTP response is sent back to the client. If `close` is
returned from the fun, something has gone wrong and the server signals this to
the client by closing the connection.
+
+> #### Note {: .info }
+>
+> It is strongly advised to use NewDataFormat in the return value of `do/1`
+> as it relies on a newer mechanism for parsing and sending headers,
+> provides more accurate status codes, and supports a wider range of Body formats.
+>
+
""".
-doc(#{title => <<"ERLANG WEB SERVER API CALLBACK FUNCTIONS">>}).
-callback do(ModData) -> {proceed, OldData} | {proceed, NewData} | {break, NewData} | done when
ModData :: [{data,NewData} | {'Body', Body} | {'Head',Head}],
OldData :: list(),
- NewData :: [{response, {StatusCode, Body}}],
+ NewData :: [{response, NewDataCompatFormat}] | [{response, NewDataFormat}],
+ NewDataCompatFormat :: {StatusCode, Body},
+ NewDataFormat :: {response, Head, Body} | {already_sent, StatusCode, Size},
StatusCode :: integer(),
+ Size :: non_neg_integer(),
Body :: iolist() | nobody | {Fun, FunArg},
- Head :: [HeaderOption],
+ Head :: [HeaderOption] | {Key, Value},
HeaderOption :: {Option, Value} | {code, StatusCode},
Option :: accept_ranges | allow,
+ Key :: atom() | string(),
Value :: string(),
FunArg :: [term()],
Fun :: fun((FunArg) -> sent | close | Body).
--
2.51.0