File 0289-inets-Widen-acceptable-timeout-responses-in-httpc_SU.patch of Package erlang

From 7a07c1a3e273992b7dcf9a8cbcaf89374d81064e Mon Sep 17 00:00:00 2001
From: Johannes Christ <jc@jchri.st>
Date: Fri, 24 Nov 2023 11:38:54 +0100
Subject: [PATCH 3/3] inets: Widen acceptable timeout responses in httpc_SUITE

Sometimes we get an extended error return as opposed to plain `{error,
timeout}`. Since the error return is documented as `{error, term()}`
regard this as fine in the test to prevent rare issues.
---
 lib/inets/test/httpc_SUITE.erl | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index 9badef17ee..c570e35ec8 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -1092,8 +1092,10 @@ bad_response(Config) when is_list(Config) ->
     RequestOpts = proplists:get_value(request_opts, Config, []),
     Profile = ?profile(Config),
 
-    {error, timeout} = httpc:request(get, {URL0, []}, [{timeout, 400},?SSL_NO_VERIFY],
-                                     RequestOpts, Profile),
+    Response = httpc:request(get, {URL0, []}, [{timeout, 400},?SSL_NO_VERIFY],
+                             RequestOpts, Profile),
+    true = is_timeout_response(Response),
+    ct:log("First response: ~p~n", [Response]),
     {error, Reason} = httpc:request(get, {URL1, []}, [?SSL_NO_VERIFY],
                                     RequestOpts, Profile),
 
@@ -1105,8 +1107,11 @@ timeout_redirect() ->
 timeout_redirect(Config) when is_list(Config) ->
     URL = url(group_name(Config), "/redirect_to_missing_crlf.html", Config),
     RequestOpts = proplists:get_value(request_opts, Config, []),
-    {error, timeout} = httpc:request(get, {URL, []}, [{timeout, 400},?SSL_NO_VERIFY],
-                                     RequestOpts, ?profile(Config)).
+    Response = httpc:request(get, {URL, []}, [{timeout, 400},?SSL_NO_VERIFY],
+                             RequestOpts, ?profile(Config)),
+    ct:log("Timeout response: ~p~n", [Response]),
+    true = is_timeout_response(Response).
+
 
 %%-------------------------------------------------------------------------
 
@@ -1439,6 +1444,12 @@ method_type(Method) ->
         patch -> write
     end.
 
+is_timeout_response({error, timeout}) -> true;
+is_timeout_response({error, {failed_connect, [{to_address, {_Host, _Port}},
+                                              {Proto, [Proto], timeout}]}}) -> true;
+is_timeout_response(_Response) -> false.
+
+
 %%-------------------------------------------------------------------------
 
 invalid_body(Config) ->
-- 
2.35.3

openSUSE Build Service is sponsored by