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 CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.3.5 - 3-Sep-2010
2
+ * Allow for custom user agent in Net::Ping::HTTP. Thanks go to Michael
3
+ Reinsch for the patch.
4
+
1
5
  == 1.3.4 - 25-Jun-2010
2
6
  * Fixed a dumb platform bug. Thanks go to Jason Frey for the spot.
3
7
 
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
- Timeout.timeout(@timeout){
57
- response = Net::HTTP.get_response(uri.host, uri_path, @port)
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
@@ -10,7 +10,7 @@ module Net
10
10
  #
11
11
  class Ping
12
12
  # The version of the net-ping library.
13
- VERSION = '1.3.4'
13
+ VERSION = '1.3.5'
14
14
 
15
15
  # The host to ping. In the case of Ping::HTTP, this is the URI.
16
16
  attr_accessor :host
data/net-ping.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'net-ping'
6
- gem.version = '1.3.4'
6
+ gem.version = '1.3.5'
7
7
  gem.license = 'Artistic 2.0'
8
8
  gem.author = 'Daniel J. Berger'
9
9
  gem.email = 'djberg96@gmail.com'
@@ -21,6 +21,6 @@ end
21
21
 
22
22
  class TC_Net_Ping < Test::Unit::TestCase
23
23
  def test_net_ping_version
24
- assert_equal('1.3.4', Net::Ping::VERSION)
24
+ assert_equal('1.3.5', Net::Ping::VERSION)
25
25
  end
26
26
  end
@@ -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
- - 4
9
- version: 1.3.4
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-06-25 00:00:00 -06:00
17
+ date: 2010-09-03 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency