blob: 08103d54320fc6eb05082611d743b6aea496a07e [file] [log] [blame]
William Lallemand039cc082021-09-24 19:02:50 +02001
2local vtc_port = 0
3
4core.register_service("fakeserv", "http", function(applet)
5 vtc_port = applet.headers["vtcport"][0]
6 core.Info("APPLET START")
7 local response = "OK"
8 applet:add_header("Server", "haproxy/webstats")
9 applet:add_header("Content-Length", string.len(response))
10 applet:add_header("Content-Type", "text/html")
11 applet:start_response()
12 applet:send(response)
13 core.Info("APPLET DONE")
14end)
15
16local function cron()
17 -- wait for until the correct port is set through the c0 request..
18 while vtc_port == 0 do
19 core.msleep(1)
20 end
21 core.Debug('CRON port:' .. vtc_port)
22
William Lallemanddc2cc902021-10-26 11:43:26 +020023 local body = ""
24
25 for i = 0, 200 do
26 body = body .. i .. ' ABCDEFGHIJKLMNOPQRSTUVWXYZ\n'
27 end
28
William Lallemand039cc082021-09-24 19:02:50 +020029 local httpclient = core.httpclient()
William Lallemanddc2cc902021-10-26 11:43:26 +020030 local response = httpclient:post{url="http://127.0.0.1:" .. vtc_port, body=body}
William Lallemand039cc082021-09-24 19:02:50 +020031
32 core.Info("Received: " .. response.body)
33end
34
35core.register_task(cron)