net-ping 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +4 -0
- data/lib/net/ping/http.rb +11 -4
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +1 -1
- data/test/test_net_ping.rb +1 -1
- data/test/test_net_ping_http.rb +5 -0
- metadata +3 -3
data/CHANGES
CHANGED
data/lib/net/ping/http.rb
CHANGED
@@ -20,7 +20,10 @@ module Net
|
|
20
20
|
# follow a redirect and will return false immediately on a redirect.
|
21
21
|
#
|
22
22
|
attr_accessor :follow_redirect
|
23
|
-
|
23
|
+
|
24
|
+
# Sets the user agent used for the HTTP request to a custom one.
|
25
|
+
attr_accessor :user_agent
|
26
|
+
|
24
27
|
# Creates and returns a new Ping::HTTP object. Note that the default
|
25
28
|
# port for Ping::HTTP is 80.
|
26
29
|
#
|
@@ -53,9 +56,13 @@ module Net
|
|
53
56
|
begin
|
54
57
|
response = nil
|
55
58
|
uri_path = uri.path.empty? ? '/' : uri.path
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
headers = { }
|
60
|
+
headers["User-Agent"] = user_agent unless user_agent.nil?
|
61
|
+
Timeout.timeout(@timeout) do
|
62
|
+
Net::HTTP.new(uri.host, @port).start do |http|
|
63
|
+
response = http.request_get(uri_path, headers)
|
64
|
+
end
|
65
|
+
end
|
59
66
|
rescue Exception => err
|
60
67
|
@exception = err.message
|
61
68
|
else
|
data/lib/net/ping/ping.rb
CHANGED
data/net-ping.gemspec
CHANGED
data/test/test_net_ping.rb
CHANGED
data/test/test_net_ping_http.rb
CHANGED
@@ -108,6 +108,11 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
108
108
|
assert_nil(@http.warning)
|
109
109
|
end
|
110
110
|
|
111
|
+
test 'ping with user agent' do
|
112
|
+
@http.user_agent = "KDDI-CA32"
|
113
|
+
assert_true(@http.ping)
|
114
|
+
end
|
115
|
+
|
111
116
|
def teardown
|
112
117
|
@uri = nil
|
113
118
|
@http = nil
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 5
|
9
|
+
version: 1.3.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel J. Berger
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-03 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|