File 0402-inets-Add-tests-for-erl_script_timeout.patch of Package erlang

From e160c628f4305dd603c24ab6d208db57ce15b23b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Dimitrov?= <peterdmv@users.noreply.github.com>
Date: Sun, 14 Apr 2019 16:35:51 +0200
Subject: [PATCH 2/2] inets: Add tests for erl_script_timeout

---
 lib/inets/src/http_server/httpd_example.erl |  21 +++-
 lib/inets/test/httpd_SUITE.erl              | 165 ++++++++++++++++++++++++++--
 2 files changed, 178 insertions(+), 8 deletions(-)

diff --git a/lib/inets/src/http_server/httpd_example.erl b/lib/inets/src/http_server/httpd_example.erl
index 37e4f97bc0..aaa7e428c2 100644
--- a/lib/inets/src/http_server/httpd_example.erl
+++ b/lib/inets/src/http_server/httpd_example.erl
@@ -24,7 +24,7 @@
 
 -export([newformat/3]).
 %% These are used by the inets test-suite
--export([delay/1, chunk_timeout/3]).
+-export([delay/1, chunk_timeout/3, get_chunks/3]).
 
 
 print(String) ->
@@ -171,3 +171,22 @@ chunk_timeout(SessionID, _, _StrInt) ->
     mod_esi:deliver(SessionID, top("Test chunk encoding timeout")),
     timer:sleep(20000),
     mod_esi:deliver(SessionID, footer()).
+
+get_chunks(Sid, _Env, In) ->
+    Tokens = string:tokens(In, [$&]),
+    PropList = lists:map(fun(E) ->
+                                 list_to_tuple(string:tokens(E,[$=])) end,
+                         Tokens),
+    HeaderDelay =
+        list_to_integer(proplists:get_value("header_delay", PropList, "0")),
+    ChunkDelay =
+        list_to_integer(proplists:get_value("chunk_delay", PropList, "0")),
+    BadChunkDelay =
+        list_to_integer(proplists:get_value("bad_chunk_delay", PropList, "0")),
+    timer:sleep(HeaderDelay),
+    mod_esi:deliver(Sid, ["Content-Type: text/plain\r\n\r\n"]),
+    mod_esi:deliver(Sid, "Chunk 0 ms\r\n"),
+    timer:sleep(ChunkDelay),
+    mod_esi:deliver(Sid, io_lib:format("Chunk ~p ms\r\n", [ChunkDelay])),
+    timer:sleep(ChunkDelay + BadChunkDelay),
+    mod_esi:deliver(Sid, "BAD Chunk\r\n").
-- 
2.16.4

openSUSE Build Service is sponsored by