# HG changeset patch # User Alain Mazy # Date 1655284262 -7200 # Node ID e0b502b31a8afced12116a8df2f2a9c6c2101a61 # Parent 5ac463ebf463bb50afa6524f25aa8060ab2783c0 fix test for older version diff -r 5ac463ebf463 -r e0b502b31a8a Database/Lua/HttpClient.lua --- 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')