File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,7 @@ def initialize(domain)
40
40
41
41
def check!
42
42
begin
43
- http = Net ::HTTP . new ( @domain )
44
- http . open_timeout = 1
45
- http . read_timeout = 1
46
- start_time = Time . now
47
- response = http . get ( '/' )
48
- end_time = Time . now
49
- @response_time = "#{ ( ( end_time - start_time ) * 1000 ) . round } ms"
50
- @code = response . code . to_i
51
- @body = response . body
52
- @status = :got_response
43
+ timed_http_request
53
44
rescue StandardError => e
54
45
@status = :errored
55
46
cause = ( 'Timeout' if e . is_a? Timeout ::Error ) || e . cause
@@ -68,6 +59,21 @@ def result
68
59
"#{ @domain } - hasn't been checked"
69
60
end
70
61
end
62
+
63
+ private
64
+
65
+ def timed_http_request
66
+ http = Net ::HTTP . new ( @domain )
67
+ http . open_timeout = 1
68
+ http . read_timeout = 1
69
+ start_time = Time . now . utc
70
+ response = http . get ( '/' )
71
+ end_time = Time . now . utc
72
+ @response_time = "#{ ( ( end_time - start_time ) * 1000 ) . round } ms"
73
+ @code = response . code . to_i
74
+ @body = response . body
75
+ @status = :got_response
76
+ end
71
77
end
72
78
73
79
# Reads domains list from a file, filters the list according to the supplied options.
You can’t perform that action at this time.
0 commit comments