changeset 481:e0b502b31a8a

fix test for older version
author Alain Mazy <am@osimis.io>
date Wed, 15 Jun 2022 11:11:02 +0200
parents 5ac463ebf463
children 535e651e70a2
files Database/Lua/HttpClient.lua
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Database/Lua/HttpClient.lua	Mon Jun 13 16:55:45 2022 +0200
+++ b/Database/Lua/HttpClient.lua	Wed Jun 15 11:11:02 2022 +0200
@@ -46,16 +46,20 @@
 if not testSucceeded then print('Failed in HttpGet') PrintRecursive(response) end
 
 
--- Test SetHttpTimeout
-SetHttpTimeout(10)
-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
+system = ParseJson(RestApiGet('/system'))
 
-SetHttpTimeout(1)
-response = HttpGet('https://httpstat.us/200?sleep=2000')
-testSucceeded = testSucceeded and (response == nil)
-if not testSucceeded then print('Failed in SetHttpTimeout2') PrintRecursive(response) end
+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)
+	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)
+	response = HttpGet('https://httpstat.us/200?sleep=2000')
+	testSucceeded = testSucceeded and (response == nil)
+	if not testSucceeded then print('Failed in SetHttpTimeout2') PrintRecursive(response) end
+end
 
 if testSucceeded then
 	print('OK')