net-http-pipeline 1.0 → 1.0.1
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.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +1 -1
- data/README.txt +1 -3
- data/Rakefile +3 -1
- data/lib/net/http/pipeline.rb +3 -3
- data/sample/pipeline.rb +21 -0
- data/test/test_net_http_pipeline.rb +59 -3
- metadata +43 -30
- metadata.gz.sig +0 -0
- data/sample/two_get.rb +0 -12
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= net-http-pipeline
|
2
2
|
|
3
|
-
* http://seattlerb.
|
3
|
+
* http://docs.seattlerb.org/net-http-pipeline
|
4
4
|
* http://github.com/drbrain/net-http-pipeline
|
5
5
|
|
6
6
|
== DESCRIPTION:
|
@@ -12,8 +12,6 @@ The server will respond in-order.
|
|
12
12
|
== FEATURES/PROBLEMS:
|
13
13
|
|
14
14
|
* Provides HTTP/1.1 pipelining
|
15
|
-
* Does not implement request wrangling per RFC 2616 8.1.2.2
|
16
|
-
* Does not handle errors
|
17
15
|
|
18
16
|
== SYNOPSIS:
|
19
17
|
|
data/Rakefile
CHANGED
@@ -5,13 +5,15 @@ require 'hoe'
|
|
5
5
|
|
6
6
|
Hoe.plugin :git
|
7
7
|
Hoe.plugin :minitest
|
8
|
-
Hoe.
|
8
|
+
Hoe.plugin :travis
|
9
9
|
|
10
10
|
Hoe.spec 'net-http-pipeline' do
|
11
11
|
developer 'Eric Hodel', 'drbrain@segment7.net'
|
12
12
|
|
13
13
|
rdoc_locations <<
|
14
14
|
'docs.seattlerb.org:/data/www/docs.seattlerb.org/net-http-pipeline/'
|
15
|
+
rdoc_locations <<
|
16
|
+
'rubyforge.org:/var/www/gforge-projects/seattlerb/net-http-pipeline/'
|
15
17
|
end
|
16
18
|
|
17
19
|
# vim: syntax=Ruby
|
data/lib/net/http/pipeline.rb
CHANGED
@@ -34,7 +34,7 @@ module Net::HTTP::Pipeline
|
|
34
34
|
##
|
35
35
|
# The version of net-http-pipeline you are using
|
36
36
|
|
37
|
-
VERSION = '1.0'
|
37
|
+
VERSION = '1.0.1'
|
38
38
|
|
39
39
|
##
|
40
40
|
# Pipeline error class
|
@@ -223,7 +223,7 @@ module Net::HTTP::Pipeline
|
|
223
223
|
begin
|
224
224
|
res = request req
|
225
225
|
rescue Timeout::Error, EOFError, Errno::ECONNABORTED, Errno::ECONNRESET,
|
226
|
-
Errno::EPIPE, Net::HTTPBadResponse => e
|
226
|
+
Errno::EPIPE, Net::HTTPBadResponse, IOError => e
|
227
227
|
if retried then
|
228
228
|
requests.unshift req
|
229
229
|
raise ResponseError.new(e, requests, responses)
|
@@ -312,7 +312,7 @@ module Net::HTTP::Pipeline
|
|
312
312
|
|
313
313
|
responses
|
314
314
|
rescue Timeout::Error, EOFError, Errno::ECONNABORTED, Errno::ECONNRESET,
|
315
|
-
Errno::EPIPE, Net::HTTPBadResponse => e
|
315
|
+
Errno::EPIPE, Net::HTTPBadResponse, IOError => e
|
316
316
|
pipeline_finish
|
317
317
|
|
318
318
|
raise ResponseError.new(e, in_flight, responses)
|
data/sample/pipeline.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'net/http/pipeline'
|
2
|
+
|
3
|
+
http = Net::HTTP.new 'localhost'
|
4
|
+
http.set_debug_output $stderr # so you can see what is happening
|
5
|
+
# http.pipelining = true # set this when localhost:80 is an HTTP/1.1 server
|
6
|
+
|
7
|
+
http.start do |http|
|
8
|
+
reqs = []
|
9
|
+
reqs << Net::HTTP::Get.new('/?a') # this request will be non-pipelined
|
10
|
+
# to check if localhost:80 is HTTP/1.1
|
11
|
+
# unless http.pipelining == true
|
12
|
+
reqs << Net::HTTP::Get.new('/?b') # these requests will be pipelined
|
13
|
+
reqs << Net::HTTP::Get.new('/?c')
|
14
|
+
|
15
|
+
http.pipeline reqs do |res|
|
16
|
+
puts res.code
|
17
|
+
puts res.body[0..60].inspect
|
18
|
+
puts
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -14,6 +14,17 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
14
14
|
@get2 = Net::HTTP::Get.new '/'
|
15
15
|
@get3 = Net::HTTP::Get.new '/'
|
16
16
|
@post = Net::HTTP::Post.new '/'
|
17
|
+
|
18
|
+
remove_start
|
19
|
+
|
20
|
+
def start
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_start
|
25
|
+
class << self
|
26
|
+
alias_method :old_start, :start if method_defined? :start
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
##
|
@@ -147,9 +158,6 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
147
158
|
r
|
148
159
|
end
|
149
160
|
|
150
|
-
def start
|
151
|
-
end
|
152
|
-
|
153
161
|
def started?() @started end
|
154
162
|
|
155
163
|
# tests start
|
@@ -273,6 +281,8 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
273
281
|
|
274
282
|
@socket = @error_socket
|
275
283
|
|
284
|
+
remove_start
|
285
|
+
|
276
286
|
def start
|
277
287
|
@socket = @good_socket
|
278
288
|
end
|
@@ -337,6 +347,8 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
337
347
|
|
338
348
|
@sockets = [@error_socket2, @good_socket]
|
339
349
|
|
350
|
+
remove_start
|
351
|
+
|
340
352
|
def start
|
341
353
|
@socket = @sockets.shift
|
342
354
|
end
|
@@ -378,6 +390,8 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
378
390
|
|
379
391
|
@socket = @error_socket
|
380
392
|
|
393
|
+
remove_start
|
394
|
+
|
381
395
|
def start
|
382
396
|
@socket = @error_socket2
|
383
397
|
end
|
@@ -446,6 +460,8 @@ class TestNetHttpPipeline < MiniTest::Unit::TestCase
|
|
446
460
|
@socket2.read_io.write http_response('Worked 1!')
|
447
461
|
@socket2.start
|
448
462
|
|
463
|
+
remove_start
|
464
|
+
|
449
465
|
def start
|
450
466
|
@socket = @socket2
|
451
467
|
end
|
@@ -481,6 +497,23 @@ Worked 1!
|
|
481
497
|
refute pipelining
|
482
498
|
end
|
483
499
|
|
500
|
+
def test_pipeline_check_ioerror
|
501
|
+
@socket = Buffer.new IOError, true
|
502
|
+
@socket.read_io.write http_response('Worked 1!')
|
503
|
+
@socket.start
|
504
|
+
|
505
|
+
requests = [@get1, @get2]
|
506
|
+
responses = []
|
507
|
+
|
508
|
+
assert_raises Net::HTTP::Pipeline::ResponseError do
|
509
|
+
pipeline_check requests, responses
|
510
|
+
end
|
511
|
+
|
512
|
+
assert_equal [@get1, @get2], requests
|
513
|
+
assert_equal 0, responses.length
|
514
|
+
refute pipelining
|
515
|
+
end
|
516
|
+
|
484
517
|
def test_pipeline_check_non_persistent
|
485
518
|
@socket = Buffer.new
|
486
519
|
@socket.read_io.write http_response('Worked 1!', 'Connection: close')
|
@@ -592,6 +625,29 @@ Worked 1!
|
|
592
625
|
assert_kind_of Errno::ECONNRESET, e.original
|
593
626
|
end
|
594
627
|
|
628
|
+
def test_pipeline_receive_ioerror
|
629
|
+
@socket = Buffer.new IOError
|
630
|
+
@socket.read_io.write http_response('Worked 1!')
|
631
|
+
@socket.start
|
632
|
+
|
633
|
+
in_flight = [@get1, @get2]
|
634
|
+
responses = []
|
635
|
+
|
636
|
+
e = assert_raises Net::HTTP::Pipeline::ResponseError do
|
637
|
+
pipeline_receive in_flight, responses
|
638
|
+
end
|
639
|
+
|
640
|
+
@socket.finish
|
641
|
+
|
642
|
+
assert @socket.closed?
|
643
|
+
|
644
|
+
assert_equal [@get2], e.requests
|
645
|
+
assert_equal 1, e.responses.length
|
646
|
+
assert_equal 'Worked 1!', e.responses.first.body
|
647
|
+
|
648
|
+
assert_kind_of IOError, e.original
|
649
|
+
end
|
650
|
+
|
595
651
|
def test_pipeline_receive_timeout
|
596
652
|
@socket = Buffer.new Timeout::Error
|
597
653
|
@socket.read_io.write http_response('Worked 1!')
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-http-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Eric Hodel
|
@@ -15,9 +16,9 @@ bindir: bin
|
|
15
16
|
cert_chain:
|
16
17
|
- |
|
17
18
|
-----BEGIN CERTIFICATE-----
|
18
|
-
|
19
|
+
MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
|
19
20
|
YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
|
20
|
-
|
21
|
+
ZXQwHhcNMTIwMjI4MTc1NDI1WhcNMTMwMjI3MTc1NDI1WjBBMRAwDgYDVQQDDAdk
|
21
22
|
cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
|
22
23
|
FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
|
23
24
|
LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
|
@@ -25,18 +26,18 @@ cert_chain:
|
|
25
26
|
Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
|
26
27
|
mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
|
27
28
|
g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
|
28
|
-
|
29
|
-
BBS5k4Z75VSpdM0AclG2UvzFA/
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
sCANiQ8BAgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
30
|
+
BBS5k4Z75VSpdM0AclG2UvzFA/VW5DAfBgNVHREEGDAWgRRkcmJyYWluQHNlZ21l
|
31
|
+
bnQ3Lm5ldDAfBgNVHRIEGDAWgRRkcmJyYWluQHNlZ21lbnQ3Lm5ldDANBgkqhkiG
|
32
|
+
9w0BAQUFAAOCAQEAPeWzFnrcvC6eVzdlhmjUub2s6qieBkongKRDHQz5MEeQv4LS
|
33
|
+
SARnoHY+uCAVL/1xGAhmpzqQ3fJGWK9eBacW/e8E5GF9xQcV3mE1bA0WNaiDlX5j
|
34
|
+
U2aI+ZGSblqvHUCxKBHR1s7UMHsbz1saOmgdRTyPx0juJs68ocbUTeYBLWu9V4KP
|
35
|
+
zdGAG2JXO2gONg3b4tYDvpBLbry+KOX27iAJulUaH9TiTOULL4ITJVFsK0mYVqmR
|
36
|
+
Q8Tno9S3e4XGGP1ZWfLrTWEJbavFfhGHut2iMRwfC7s/YILAHNATopaJdH9DNpd1
|
37
|
+
U81zGHMUBOvz/VGT6wJwYJ3emS2nfA2NOHFfgA==
|
36
38
|
-----END CERTIFICATE-----
|
37
39
|
|
38
|
-
date:
|
39
|
-
default_executable:
|
40
|
+
date: 2012-04-13 00:00:00 Z
|
40
41
|
dependencies:
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: minitest
|
@@ -44,32 +45,45 @@ dependencies:
|
|
44
45
|
requirement: &id001 !ruby/object:Gem::Requirement
|
45
46
|
none: false
|
46
47
|
requirements:
|
47
|
-
- -
|
48
|
+
- - ~>
|
48
49
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
50
|
+
hash: 21
|
50
51
|
segments:
|
51
52
|
- 2
|
52
|
-
-
|
53
|
-
|
54
|
-
version: 2.0.2
|
53
|
+
- 11
|
54
|
+
version: "2.11"
|
55
55
|
type: :development
|
56
56
|
version_requirements: *id001
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: rdoc
|
59
59
|
prerelease: false
|
60
60
|
requirement: &id002 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ~>
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
hash:
|
65
|
+
hash: 19
|
66
66
|
segments:
|
67
|
-
-
|
68
|
-
-
|
69
|
-
|
70
|
-
version: 2.9.1
|
67
|
+
- 3
|
68
|
+
- 10
|
69
|
+
version: "3.10"
|
71
70
|
type: :development
|
72
71
|
version_requirements: *id002
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: hoe
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 35
|
81
|
+
segments:
|
82
|
+
- 2
|
83
|
+
- 16
|
84
|
+
version: "2.16"
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id003
|
73
87
|
description: |-
|
74
88
|
An HTTP/1.1 pipelining implementation atop Net::HTTP. A pipelined connection
|
75
89
|
sends multiple requests to the HTTP server without waiting for the responses.
|
@@ -91,11 +105,10 @@ files:
|
|
91
105
|
- README.txt
|
92
106
|
- Rakefile
|
93
107
|
- lib/net/http/pipeline.rb
|
94
|
-
- sample/
|
108
|
+
- sample/pipeline.rb
|
95
109
|
- test/test_net_http_pipeline.rb
|
96
110
|
- .gemtest
|
97
|
-
|
98
|
-
homepage: http://seattlerb.rubyforge.org/net-http-pipeline
|
111
|
+
homepage: http://docs.seattlerb.org/net-http-pipeline
|
99
112
|
licenses: []
|
100
113
|
|
101
114
|
post_install_message:
|
@@ -125,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
138
|
requirements: []
|
126
139
|
|
127
140
|
rubyforge_project: net-http-pipeline
|
128
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.8.21
|
129
142
|
signing_key:
|
130
143
|
specification_version: 3
|
131
144
|
summary: An HTTP/1.1 pipelining implementation atop Net::HTTP
|
metadata.gz.sig
CHANGED
Binary file
|
data/sample/two_get.rb
DELETED