Mercurial > hg > orthanc-tests
comparison Database/Lua/HttpClient.lua @ 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 | cffef67c9a94 |
comparison
equal
deleted
inserted
replaced
480:5ac463ebf463 | 481:e0b502b31a8a |
---|---|
44 response = ParseJson(HttpGet('http://httpbin.org/get', httpHeaders)) | 44 response = ParseJson(HttpGet('http://httpbin.org/get', httpHeaders)) |
45 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | 45 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') |
46 if not testSucceeded then print('Failed in HttpGet') PrintRecursive(response) end | 46 if not testSucceeded then print('Failed in HttpGet') PrintRecursive(response) end |
47 | 47 |
48 | 48 |
49 -- Test SetHttpTimeout | 49 system = ParseJson(RestApiGet('/system')) |
50 SetHttpTimeout(10) | |
51 response = HttpGet('https://httpstat.us/200?sleep=1000') | |
52 testSucceeded = testSucceeded and (response == '200 OK') | |
53 if not testSucceeded then print('Failed in SetHttpTimeout1') PrintRecursive(response) end | |
54 | 50 |
55 SetHttpTimeout(1) | 51 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 :-) ) |
56 response = HttpGet('https://httpstat.us/200?sleep=2000') | 52 -- Test SetHttpTimeout |
57 testSucceeded = testSucceeded and (response == nil) | 53 SetHttpTimeout(10) |
58 if not testSucceeded then print('Failed in SetHttpTimeout2') PrintRecursive(response) end | 54 response = HttpGet('https://httpstat.us/200?sleep=1000') |
55 testSucceeded = testSucceeded and (response == '200 OK') | |
56 if not testSucceeded then print('Failed in SetHttpTimeout1') PrintRecursive(response) end | |
57 | |
58 SetHttpTimeout(1) | |
59 response = HttpGet('https://httpstat.us/200?sleep=2000') | |
60 testSucceeded = testSucceeded and (response == nil) | |
61 if not testSucceeded then print('Failed in SetHttpTimeout2') PrintRecursive(response) end | |
62 end | |
59 | 63 |
60 if testSucceeded then | 64 if testSucceeded then |
61 print('OK') | 65 print('OK') |
62 else | 66 else |
63 print('FAILED') | 67 print('FAILED') |