summaryrefslogtreecommitdiff
path: root/lib/custodian/protocol-tests/https.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-14 16:05:03 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-14 16:05:03 +0000
commitdff1f98662289589ca6227bffa885f90b5773e62 (patch)
treeea4c7718d46e252d583dd37bdd0c502025ee8e27 /lib/custodian/protocol-tests/https.rb
parente880c1890738793d176c6d07e35666116fc34514 (diff)
Updated each test to use the timeout period specified in the JSON
hash. Update the trivial test to set such a thing too.
Diffstat (limited to 'lib/custodian/protocol-tests/https.rb')
-rwxr-xr-xlib/custodian/protocol-tests/https.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/custodian/protocol-tests/https.rb b/lib/custodian/protocol-tests/https.rb
index 8db4da5..ec2597b 100755
--- a/lib/custodian/protocol-tests/https.rb
+++ b/lib/custodian/protocol-tests/https.rb
@@ -68,7 +68,7 @@ class HTTPSTest
# Do the fetch, if this success then we'll have the
# @status + @text setup
#
- if ( getURL (@test_data["target_host"] ) )
+ if ( getURL(@test_data["target_host"], @test_data["timeout"] ) )
#
# Do we need to test for a HTTP status code?
@@ -115,13 +115,13 @@ class HTTPSTest
# Retrieve a HTTP page from the web.
#
# NOTE: This came from sentinel.
- def getURL (uri_str)
+ def getURL (uri_str, timeout)
begin
uri_str = 'http://' + uri_str unless uri_str.match(/^http/)
url = URI.parse(uri_str)
http = Net::HTTP.new(url.host, url.port)
- http.open_timeout = 3
- http.read_timeout = 3
+ http.open_timeout = timeout
+ http.read_timeout = timeout
if (url.scheme == "https")
http.use_ssl = true
@@ -148,7 +148,7 @@ class HTTPSTest
then
newURL = response['location'].match(/^http/)?
response['Location']:uri_str+response['Location']
- return( getURL(newURL) )
+ return( getURL(newURL, timeout) )
else
@status = response.code.to_i
@body = response.body
@@ -190,6 +190,7 @@ if __FILE__ == $0 then
"target_host" => "http://www.steve.org.uk/",
"test_type" => "http",
"verbose" => 1,
+ "timeout" => 5,
"test_port" => 80,
"test_alert" => "Steve's website is unavailable",
"http_text" => "Steve Kemp",