net-http-persistent 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,6 +1,13 @@
1
- === 1.0.0 / 2010-05-04
1
+ === 1.0.1 / 2010-05-05
2
+
3
+ * Minor Enhancements
4
+ * Added #debug_output
5
+ * Now uses Hoe minitest plugin
6
+ * Bug fixes
7
+ * Tests pass on 1.9
2
8
 
3
- * 1 major enhancement
9
+ === 1.0.0 / 2010-05-04
4
10
 
11
+ * Major Enhancements
5
12
  * Birthday!
6
13
 
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
 
6
6
  Hoe.plugin :git
7
+ Hoe.plugin :minitest
7
8
 
8
9
  Hoe.spec 'net-http-persistent' do |p|
9
10
  self.rubyforge_name = 'seattlerb'
@@ -29,7 +29,7 @@ class Net::HTTP::Persistent
29
29
  ##
30
30
  # The version of Net::HTTP::Persistent use are using
31
31
 
32
- VERSION = '1.0'
32
+ VERSION = '1.0.1'
33
33
 
34
34
  ##
35
35
  # Error class for errors raised by Net::HTTP::Persistent. Various
@@ -49,6 +49,14 @@ class Net::HTTP::Persistent
49
49
 
50
50
  attr_accessor :ca_file
51
51
 
52
+ ##
53
+ # Sends debug_output to this IO via Net::HTTP#set_debug_output.
54
+ #
55
+ # Never use this method in production code, it causes a serious security
56
+ # hole.
57
+
58
+ attr_accessor :debug_output
59
+
52
60
  ##
53
61
  # Headers that are added to every request
54
62
 
@@ -78,8 +86,9 @@ class Net::HTTP::Persistent
78
86
  attr_accessor :verify_mode
79
87
 
80
88
  def initialize # :nodoc:
81
- @keep_alive = 30
82
- @headers = {}
89
+ @debug_output = nil
90
+ @headers = {}
91
+ @keep_alive = 30
83
92
 
84
93
  @certificate = nil
85
94
  @ca_file = nil
@@ -100,9 +109,13 @@ class Net::HTTP::Persistent
100
109
  connections[connection_id] ||= Net::HTTP.new uri.host, uri.port
101
110
  connection = connections[connection_id]
102
111
 
103
- ssl connection if uri.scheme == 'https' and not connection.started?
112
+ unless connection.started? then
113
+ connection.set_debug_output @debug_output if @debug_output
114
+
115
+ ssl connection if uri.scheme == 'https'
104
116
 
105
- connection.start unless connection.started?
117
+ connection.start
118
+ end
106
119
 
107
120
  connection
108
121
  rescue Errno::ECONNREFUSED
@@ -1,6 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'net/http/persistent'
3
3
  require 'openssl'
4
+ require 'stringio'
4
5
 
5
6
  class TestNetHttpPersistent < MiniTest::Unit::TestCase
6
7
 
@@ -59,6 +60,19 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
59
60
  assert_same cached, c
60
61
  end
61
62
 
63
+ def test_connection_for_debug_output
64
+ io = StringIO.new
65
+ @http.debug_output = io
66
+
67
+ c = @http.connection_for @uri
68
+
69
+ assert c.started?
70
+ assert_equal io, c.instance_variable_get(:@debug_output)
71
+
72
+ assert_includes conns.keys, 'example.com:80'
73
+ assert_same c, conns['example.com:80']
74
+ end
75
+
62
76
  def test_connection_for_refused
63
77
  cached = Object.new
64
78
  def cached.address; 'example.com' end
@@ -71,7 +85,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
71
85
  @http.connection_for @uri
72
86
  end
73
87
 
74
- assert_match %r%connection refused%, e
88
+ assert_match %r%connection refused%, e.message
75
89
  end
76
90
 
77
91
  def test_error_message
@@ -122,7 +136,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
122
136
  @http.reset c
123
137
  end
124
138
 
125
- assert_match %r%host down%, e
139
+ assert_match %r%host down%, e.message
126
140
  end
127
141
 
128
142
  def test_reset_refused
@@ -137,7 +151,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
137
151
  @http.reset c
138
152
  end
139
153
 
140
- assert_match %r%connection refused%, e
154
+ assert_match %r%connection refused%, e.message
141
155
  end
142
156
 
143
157
  def test_request
@@ -153,7 +167,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
153
167
  assert_equal '/path', req.path
154
168
  assert_equal 'keep-alive', req['connection']
155
169
  assert_equal '30', req['keep-alive']
156
- assert_equal 'test ua', req['user-agent']
170
+ assert_match %r%test ua%, req['user-agent']
157
171
 
158
172
  assert_equal 1, reqs[c.object_id]
159
173
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-persistent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- version: "1.0"
9
+ - 1
10
+ version: 1.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Eric Hodel
@@ -35,7 +36,7 @@ cert_chain:
35
36
  x52qPcexcYZR7w==
36
37
  -----END CERTIFICATE-----
37
38
 
38
- date: 2010-05-04 00:00:00 -07:00
39
+ date: 2010-05-05 00:00:00 -07:00
39
40
  default_executable:
40
41
  dependencies:
41
42
  - !ruby/object:Gem::Dependency
@@ -71,9 +72,25 @@ dependencies:
71
72
  type: :development
72
73
  version_requirements: *id002
73
74
  - !ruby/object:Gem::Dependency
74
- name: hoe
75
+ name: minitest
75
76
  prerelease: false
76
77
  requirement: &id003 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 1
85
+ - 5
86
+ - 0
87
+ version: 1.5.0
88
+ type: :development
89
+ version_requirements: *id003
90
+ - !ruby/object:Gem::Dependency
91
+ name: hoe
92
+ prerelease: false
93
+ requirement: &id004 !ruby/object:Gem::Requirement
77
94
  none: false
78
95
  requirements:
79
96
  - - ">="
@@ -85,7 +102,7 @@ dependencies:
85
102
  - 0
86
103
  version: 2.5.0
87
104
  type: :development
88
- version_requirements: *id003
105
+ version_requirements: *id004
89
106
  description: |-
90
107
  Persistent connections using Net::HTTP plus a speed fix for 1.8. It's
91
108
  thread-safe too!
metadata.gz.sig CHANGED
Binary file