# HG changeset patch
# User Alain Mazy <am@osimis.io>
# Date 1660721867 -7200
# Node ID 75d8a5261f8242e6108a8eb5ff32f347823e9ac6
# Parent  cffef67c9a945d334faabdc28b708a144b6c1770
more verbose httpclient test

diff -r cffef67c9a94 -r 75d8a5261f82 Database/Lua/HttpClient.lua
--- a/Database/Lua/HttpClient.lua	Wed Aug 10 15:15:20 2022 +0200
+++ b/Database/Lua/HttpClient.lua	Wed Aug 17 09:37:47 2022 +0200
@@ -14,6 +14,7 @@
 retry = 10
 response = nil
 while retry > 0 and response == nil do
+	print("HttpClient test: POST with body to httpbin.org")
 	response = ParseJson(HttpPost('http://httpbin.org/post', DumpJson(payload), httpHeaders))
 end
 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu')
@@ -24,6 +25,7 @@
 retry = 10
 response = nil
 while retry > 0 and response == nil do
+	print("HttpClient test: POST without body to httpbin.org")
 	response = ParseJson(HttpPost('http://httpbin.org/post', nil, httpHeaders))
 end
 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu')
@@ -34,6 +36,7 @@
 retry = 10
 response = nil
 while retry > 0 and response == nil do
+	print("HttpClient test: PUT with body to httpbin.org")
 	response = ParseJson(HttpPut('http://httpbin.org/put', DumpJson(payload), httpHeaders))
 end
 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu')
@@ -44,6 +47,7 @@
 retry = 10
 response = nil
 while retry > 0 and response == nil do
+	print("HttpClient test: PUT without body to httpbin.org")
 	response = ParseJson(HttpPut('http://httpbin.org/put', nil, httpHeaders))
 end
 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu')
@@ -60,7 +64,9 @@
 retry = 10
 response = nil
 while retry > 0 and response == nil do
+	print("HttpClient test: GET to httpbin.org")
 	response = ParseJson(HttpGet('http://httpbin.org/get', httpHeaders))
+	sleep(1)
 end
 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu')
 if not testSucceeded then print('Failed in HttpGet') PrintRecursive(response) end
@@ -71,11 +77,13 @@
 if system['Version'] == 'mainline' or system['Version'] == '1.11.1' or system['ApiVersion'] >= 18 then  -- introduced in 1.11.1 which is ApiVersion 17 (too lazy to reimplement IsAboveOrthancVersion in lua :-) )
 	-- Test SetHttpTimeout
 	SetHttpTimeout(10)
+	print("HttpClient test: GET with timeout (10) to httpstat.us")
 	response = HttpGet('https://httpstat.us/200?sleep=1000')
 	testSucceeded = testSucceeded and (response == '200 OK')
 	if not testSucceeded then print('Failed in SetHttpTimeout1') PrintRecursive(response) end
 
 	SetHttpTimeout(1)
+	print("HttpClient test: GET with timeout (1) to httpstat.us")
 	response = HttpGet('https://httpstat.us/200?sleep=2000')
 	testSucceeded = testSucceeded and (response == nil)
 	if not testSucceeded then print('Failed in SetHttpTimeout2') PrintRecursive(response) end