http_spew 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.manifest +6 -0
- data/ChangeLog +303 -0
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +11 -0
- data/Gemfile +5 -0
- data/LATEST +5 -2
- data/NEWS +7 -0
- data/http_spew.gemspec +2 -2
- data/lib/http_spew/chunky_pipe.rb +18 -4
- data/lib/http_spew/class_methods.rb +125 -0
- data/lib/http_spew/content_md5.rb +36 -26
- data/lib/http_spew/headers.rb +11 -0
- data/lib/http_spew/hit_n_run.rb +2 -0
- data/lib/http_spew/input_spray.rb +19 -27
- data/lib/http_spew/request.rb +65 -11
- data/lib/http_spew/version.rb +2 -0
- data/lib/http_spew.rb +13 -83
- data/pkg.mk +4 -0
- data/test/content-md5.ru +3 -1
- data/test/helper.rb +4 -1
- data/test/response_code.ru +20 -0
- data/test/test_content_md5.rb +14 -13
- data/test/test_input_spray.rb +12 -13
- data/test/test_input_spray_with_md5.rb +107 -0
- data/test/test_mirror.rb +7 -7
- data/test/test_request.rb +2 -2
- data/test/test_unexpected_response.rb +47 -0
- data/test/test_upload.rb +21 -19
- metadata +20 -13
data/test/test_request.rb
CHANGED
@@ -31,12 +31,12 @@ class TestRequest < Test::Unit::TestCase
|
|
31
31
|
sym = req.resume
|
32
32
|
assert_kind_of(Symbol, sym)
|
33
33
|
if sym == :wait_writable
|
34
|
-
set = Kgio.poll({req => sym},
|
34
|
+
set = Kgio.poll({req => sym}, 1000)
|
35
35
|
assert_equal [ req ], set.keys
|
36
36
|
sym = req.resume
|
37
37
|
end
|
38
38
|
assert_equal :wait_readable, sym
|
39
|
-
set = Kgio.poll({req => sym},
|
39
|
+
set = Kgio.poll({req => sym}, 1000)
|
40
40
|
assert_equal [ req ], set.keys
|
41
41
|
rv = req.resume
|
42
42
|
assert_equal req, rv[2]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "./test/helper"
|
2
|
+
|
3
|
+
class TestRequest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@addr, @port, @srv = start_server("./test/response_code.ru", 1)
|
6
|
+
@sockaddr = Socket.pack_sockaddr_in(@port, @addr)
|
7
|
+
@env = {
|
8
|
+
"REQUEST_METHOD" => "PUT",
|
9
|
+
"REQUEST_URI" => "/",
|
10
|
+
"HTTP_HOST" => "example.com",
|
11
|
+
}
|
12
|
+
@tmpfiles = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
Process.kill(:QUIT, @srv)
|
17
|
+
Process.waitpid2(@srv)
|
18
|
+
@tmpfiles.each { |tmp| tmp.closed? or tmp.close! }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_request_with_existing_socket
|
22
|
+
sock = Kgio::Socket.new(@sockaddr)
|
23
|
+
req = HTTP_Spew::Request.new(@env, nil, sock)
|
24
|
+
assert_equal sock, req.to_io
|
25
|
+
assert_nothing_raised { req.close }
|
26
|
+
assert sock.closed?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_request_single_unexpected
|
30
|
+
io = StringIO.new("")
|
31
|
+
req = HTTP_Spew::Request.new(@env, io, @sockaddr, { 201 => true })
|
32
|
+
rv = req.run(4)
|
33
|
+
assert_instance_of HTTP_Spew::UnexpectedResponse, rv
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_request_single_expected
|
37
|
+
io = StringIO.new("")
|
38
|
+
@env["HTTP_X_RESPONSE_CODE"] = "201"
|
39
|
+
req = HTTP_Spew::Request.new(@env, io, @sockaddr, { 201 => true })
|
40
|
+
rv = req.run(4)
|
41
|
+
assert_instance_of Array, rv
|
42
|
+
assert_equal 201, rv[0].to_i
|
43
|
+
buf = ""
|
44
|
+
rv[2].each { |chunk| buf << chunk }
|
45
|
+
assert_equal "da39a3ee5e6b4b0d3255bfef95601890afd80709\n", buf
|
46
|
+
end
|
47
|
+
end
|
data/test/test_upload.rb
CHANGED
@@ -24,11 +24,11 @@ class TestUpload < Test::Unit::TestCase
|
|
24
24
|
req << HTTP_Spew::Request.new(@env, nil, @sockaddr)
|
25
25
|
req << HTTP_Spew::Request.new(@env, nil, @sockaddr)
|
26
26
|
req << HTTP_Spew::Request.new(@env, nil, @sockaddr)
|
27
|
-
rv = HTTP_Spew.wait(3, req,
|
27
|
+
rv = HTTP_Spew.wait(3, req, 666)
|
28
28
|
assert_equal 3, rv.size
|
29
|
-
rv.each do |
|
30
|
-
assert_nil
|
31
|
-
response =
|
29
|
+
rv.each do |r|
|
30
|
+
assert_nil r.error
|
31
|
+
response = r.response
|
32
32
|
assert_equal 200, response[0].to_i
|
33
33
|
tmp = []
|
34
34
|
response[2].each { |x| tmp << x.dup }
|
@@ -53,11 +53,11 @@ class TestUpload < Test::Unit::TestCase
|
|
53
53
|
req << HTTP_Spew::Request.new(@env, tmp_blob(str), @sockaddr)
|
54
54
|
req << HTTP_Spew::Request.new(@env, tmp_blob(str), @sockaddr)
|
55
55
|
req << HTTP_Spew::Request.new(@env, tmp_blob(str), @sockaddr)
|
56
|
-
rv = HTTP_Spew.wait(3, req,
|
56
|
+
rv = HTTP_Spew.wait(3, req, 666)
|
57
57
|
assert_equal 3, rv.size
|
58
|
-
rv.each do |
|
59
|
-
assert_nil
|
60
|
-
response =
|
58
|
+
rv.each do |r|
|
59
|
+
assert_nil r.error
|
60
|
+
response = r.response
|
61
61
|
assert_equal 200, response[0].to_i
|
62
62
|
tmp = []
|
63
63
|
response[2].each { |x| tmp << x.dup }
|
@@ -72,11 +72,11 @@ class TestUpload < Test::Unit::TestCase
|
|
72
72
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
73
73
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
74
74
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
75
|
-
rv = HTTP_Spew.wait(3, req,
|
75
|
+
rv = HTTP_Spew.wait(3, req, 666)
|
76
76
|
assert_equal 3, rv.size
|
77
|
-
rv.each do |
|
78
|
-
assert_nil
|
79
|
-
response =
|
77
|
+
rv.each do |r|
|
78
|
+
assert_nil r.error
|
79
|
+
response = r.response
|
80
80
|
assert_equal 200, response[0].to_i
|
81
81
|
tmp = []
|
82
82
|
response[2].each { |x| tmp << x.dup }
|
@@ -91,17 +91,17 @@ class TestUpload < Test::Unit::TestCase
|
|
91
91
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
92
92
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
93
93
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
94
|
-
rv = HTTP_Spew.wait(2, req,
|
94
|
+
rv = HTTP_Spew.wait(2, req, 666)
|
95
95
|
assert_equal 3, rv.size
|
96
|
-
rv[0, 2].each do |
|
97
|
-
assert_nil
|
98
|
-
response =
|
96
|
+
rv[0, 2].each do |r|
|
97
|
+
assert_nil r.error
|
98
|
+
response = r.response
|
99
99
|
assert_equal 200, response[0].to_i
|
100
100
|
tmp = []
|
101
101
|
response[2].each { |x| tmp << x.dup }
|
102
102
|
assert_equal expect, tmp
|
103
103
|
assert_nothing_raised { response[2].close }
|
104
|
-
assert
|
104
|
+
assert r.to_io.closed?
|
105
105
|
end
|
106
106
|
failed = rv[2]
|
107
107
|
assert_kind_of(HTTP_Spew::ConnectionReset, failed.error)
|
@@ -114,14 +114,16 @@ class TestUpload < Test::Unit::TestCase
|
|
114
114
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
115
115
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
116
116
|
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
117
|
+
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
118
|
+
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
119
|
+
req << HTTP_Spew::Request.new(@env, StringIO.new(str), @sockaddr)
|
117
120
|
before = req.dup
|
118
121
|
rv = HTTP_Spew.wait_nonblock!(3, req)
|
119
|
-
assert_nil rv
|
120
122
|
while rv.nil? do
|
121
123
|
rv = HTTP_Spew.wait_nonblock!(3, req)
|
122
124
|
end
|
123
125
|
assert_nil rv.uniq!
|
124
126
|
assert rv.size > 0
|
125
|
-
rv.each { |
|
127
|
+
rv.each { |r| assert before.include?(r) }
|
126
128
|
end
|
127
129
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_spew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- HTTP Spew hackers
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-05-10 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: kcar
|
@@ -26,12 +25,11 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
28
|
+
hash: 15
|
30
29
|
segments:
|
31
30
|
- 0
|
32
|
-
- 1
|
33
31
|
- 2
|
34
|
-
version: 0.
|
32
|
+
version: "0.2"
|
35
33
|
type: :runtime
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
@@ -42,11 +40,11 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 11
|
46
44
|
segments:
|
47
45
|
- 2
|
48
|
-
-
|
49
|
-
version: "2.
|
46
|
+
- 4
|
47
|
+
version: "2.4"
|
50
48
|
type: :runtime
|
51
49
|
version_requirements: *id002
|
52
50
|
- !ruby/object:Gem::Dependency
|
@@ -81,11 +79,13 @@ extra_rdoc_files:
|
|
81
79
|
- ChangeLog
|
82
80
|
- lib/http_spew.rb
|
83
81
|
- lib/http_spew/chunky_pipe.rb
|
82
|
+
- lib/http_spew/class_methods.rb
|
84
83
|
- lib/http_spew/content_md5.rb
|
85
84
|
- lib/http_spew/headers.rb
|
86
85
|
- lib/http_spew/hit_n_run.rb
|
87
86
|
- lib/http_spew/input_spray.rb
|
88
87
|
- lib/http_spew/request.rb
|
88
|
+
- lib/http_spew/version.rb
|
89
89
|
files:
|
90
90
|
- .document
|
91
91
|
- .gitignore
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- GIT-VERSION-FILE
|
97
97
|
- GIT-VERSION-GEN
|
98
98
|
- GNUmakefile
|
99
|
+
- Gemfile
|
99
100
|
- LATEST
|
100
101
|
- LICENSE
|
101
102
|
- NEWS
|
@@ -103,24 +104,28 @@ files:
|
|
103
104
|
- http_spew.gemspec
|
104
105
|
- lib/http_spew.rb
|
105
106
|
- lib/http_spew/chunky_pipe.rb
|
107
|
+
- lib/http_spew/class_methods.rb
|
106
108
|
- lib/http_spew/content_md5.rb
|
107
109
|
- lib/http_spew/headers.rb
|
108
110
|
- lib/http_spew/hit_n_run.rb
|
109
111
|
- lib/http_spew/input_spray.rb
|
110
112
|
- lib/http_spew/request.rb
|
113
|
+
- lib/http_spew/version.rb
|
111
114
|
- pkg.mk
|
112
115
|
- setup.rb
|
113
116
|
- test/content-md5.ru
|
114
117
|
- test/helper.rb
|
115
118
|
- test/mirror.ru
|
119
|
+
- test/response_code.ru
|
116
120
|
- test/sha1.ru
|
117
121
|
- test/test_content_md5.rb
|
118
122
|
- test/test_hit_n_run.rb
|
119
123
|
- test/test_input_spray.rb
|
124
|
+
- test/test_input_spray_with_md5.rb
|
120
125
|
- test/test_mirror.rb
|
121
126
|
- test/test_request.rb
|
127
|
+
- test/test_unexpected_response.rb
|
122
128
|
- test/test_upload.rb
|
123
|
-
has_rdoc: true
|
124
129
|
homepage: http://bogomips.org/http_spew/
|
125
130
|
licenses: []
|
126
131
|
|
@@ -153,14 +158,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
158
|
requirements: []
|
154
159
|
|
155
160
|
rubyforge_project: rainbows
|
156
|
-
rubygems_version: 1.
|
161
|
+
rubygems_version: 1.8.1
|
157
162
|
signing_key:
|
158
163
|
specification_version: 3
|
159
164
|
summary: LAN-only HTTP spam^H^H^H^Hclient for Ruby
|
160
165
|
test_files:
|
166
|
+
- test/test_input_spray_with_md5.rb
|
161
167
|
- test/test_mirror.rb
|
162
168
|
- test/test_request.rb
|
163
169
|
- test/test_upload.rb
|
170
|
+
- test/test_unexpected_response.rb
|
164
171
|
- test/test_content_md5.rb
|
165
172
|
- test/test_input_spray.rb
|
166
173
|
- test/test_hit_n_run.rb
|