http_spew 0.4.1 → 0.5.0
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.
- checksums.yaml +7 -0
- data/.document +0 -1
- data/.gitignore +1 -4
- data/.manifest +3 -3
- data/.olddoc.yml +7 -0
- data/COPYING +288 -623
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +1 -2
- data/LATEST +18 -2
- data/LICENSE +8 -11
- data/NEWS +20 -0
- data/README +4 -5
- data/benchmark/bm_content_md5.rb +52 -0
- data/benchmark/bm_content_md5_input_spray.rb +59 -0
- data/http_spew.gemspec +9 -10
- data/lib/http_spew/class_methods.rb +6 -6
- data/lib/http_spew/content_md5.rb +5 -6
- data/lib/http_spew/headers.rb +8 -17
- data/lib/http_spew/request.rb +4 -4
- data/lib/http_spew/version.rb +1 -1
- data/lib/http_spew.rb +13 -13
- data/pkg.mk +26 -51
- data/test/helper.rb +3 -1
- data/test/test_content_md5.rb +1 -1
- data/test/test_hit_n_run.rb +1 -1
- data/test/test_input_spray_with_md5.rb +3 -3
- data/test/test_mirror.rb +1 -1
- data/test/test_request.rb +1 -1
- data/test/test_unexpected_response.rb +1 -1
- data/test/test_upload.rb +6 -3
- metadata +39 -46
- data/.wrongdoc.yml +0 -4
- data/ChangeLog +0 -546
- data/Gemfile +0 -5
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 0.
|
1
|
+
GIT_VERSION = 0.5.0
|
data/GIT-VERSION-GEN
CHANGED
data/GNUmakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
all::
|
2
2
|
RSYNC_DEST := bogomips.org:/srv/bogomips/http_spew
|
3
|
-
rfproject := rainbows
|
4
3
|
rfpackage := http_spew
|
5
4
|
|
6
5
|
RUBY_VERSION_FILE = lib/http_spew/version.rb
|
@@ -10,7 +9,7 @@ include pkg.mk
|
|
10
9
|
$(RUBY_VERSION_FILE): GIT-VERSION-FILE
|
11
10
|
@$(RM) -f $@+
|
12
11
|
@echo >> $@+ '# -*- encoding: binary -*-'
|
13
|
-
@echo >> $@+ 'HTTP_Spew.const_set :VERSION, "$(GIT_VERSION)"'
|
12
|
+
@echo >> $@+ 'HTTP_Spew.const_set :VERSION, "$(GIT_VERSION)".freeze'
|
14
13
|
@mv $@+ $@
|
15
14
|
|
16
15
|
build: $(RUBY_VERSION_FILE)
|
data/LATEST
CHANGED
@@ -1,4 +1,20 @@
|
|
1
|
-
=== http_spew 0.
|
1
|
+
=== http_spew 0.5.0 / 2016-10-31 20:43 UTC
|
2
2
|
|
3
|
-
|
3
|
+
This release requires Ruby 2.1 or later.
|
4
|
+
|
5
|
+
13 changes since 0.4.1:
|
6
|
+
|
7
|
+
gemspec: require kcar >= 0.3.1
|
8
|
+
test/helper: explicit redirect for Ruby 2.0.0
|
9
|
+
update packaging + docs (website)
|
10
|
+
allow all future GPL versions
|
11
|
+
add benchmark scripts
|
12
|
+
relax dependency on unicorn
|
13
|
+
declare empty classes with constant assignment
|
14
|
+
test_upload: use object_id to check matches
|
15
|
+
use frozen string literals for Ruby 2.1+
|
16
|
+
merge into kcar project and mailing list
|
17
|
+
dedicated mailing list
|
18
|
+
rely on opt_str_freeze in more places
|
19
|
+
use monotonic clock for timing
|
4
20
|
|
data/LICENSE
CHANGED
@@ -1,17 +1,14 @@
|
|
1
|
-
|
1
|
+
http_spew is copyrighted Free Software by all contributors, see logs in
|
2
2
|
revision control for names and email addresses of all of them.
|
3
3
|
|
4
4
|
You can redistribute it and/or modify it under the terms of the GNU
|
5
|
-
General Public License
|
6
|
-
|
7
|
-
(Eric Wong) reserves the right to relicense HTTP Spew under future versions
|
8
|
-
of the GPL.
|
5
|
+
General Public License as published by the Free Software Foundation;
|
6
|
+
either version 2 of the License, or (at your option) any later version.
|
9
7
|
|
10
|
-
|
8
|
+
http_spew is distributed in the hope that it will be useful, but WITHOUT
|
11
9
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
12
|
-
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
13
|
-
|
10
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
11
|
+
for more details.
|
14
12
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
16
|
-
|
17
|
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
13
|
+
You should have received a copy of the GNU General Public License along
|
14
|
+
with this program; if not, see https://www.gnu.org/licenses/gpl-2.0.txt
|
data/NEWS
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
=== http_spew 0.5.0 / 2016-10-31 20:43 UTC
|
2
|
+
|
3
|
+
This release requires Ruby 2.1 or later.
|
4
|
+
|
5
|
+
13 changes since 0.4.1:
|
6
|
+
|
7
|
+
gemspec: require kcar >= 0.3.1
|
8
|
+
test/helper: explicit redirect for Ruby 2.0.0
|
9
|
+
update packaging + docs (website)
|
10
|
+
allow all future GPL versions
|
11
|
+
add benchmark scripts
|
12
|
+
relax dependency on unicorn
|
13
|
+
declare empty classes with constant assignment
|
14
|
+
test_upload: use object_id to check matches
|
15
|
+
use frozen string literals for Ruby 2.1+
|
16
|
+
merge into kcar project and mailing list
|
17
|
+
dedicated mailing list
|
18
|
+
rely on opt_str_freeze in more places
|
19
|
+
use monotonic clock for timing
|
20
|
+
|
1
21
|
=== http_spew 0.4.1 / 2012-09-23 00:01 UTC
|
2
22
|
|
3
23
|
Fix formatting of user-supplied headers.
|
data/README
CHANGED
@@ -11,7 +11,6 @@ Use HTTP Spew if you wish you could kinda multicast with HTTP...
|
|
11
11
|
* No support for DNS resolution (WONTFIX, ever)
|
12
12
|
* No support for HTTPS
|
13
13
|
* No support for keepalive (yet?)
|
14
|
-
* No support for Ruby 1.8, this is Ruby 1.9-only
|
15
14
|
* Not remotely RFC-compliant
|
16
15
|
* Messes up analytics/reporting on servers
|
17
16
|
* Resets server connections
|
@@ -39,7 +38,7 @@ You can get the latest source via git from the following locations:
|
|
39
38
|
You may browse the code from the web and download the latest snapshot
|
40
39
|
tarballs here:
|
41
40
|
|
42
|
-
*
|
41
|
+
* https://bogomips.org/http_spew.git
|
43
42
|
* http://repo.or.cz/w/http_spew.git (gitweb)
|
44
43
|
|
45
44
|
Inline patches (from "git format-patch") to the mailing list are
|
@@ -54,8 +53,8 @@ don't email the git mailing list or maintainer with http_spew patches.
|
|
54
53
|
== Contact
|
55
54
|
|
56
55
|
All feedback (bug reports, user/development discussion, patches, pull
|
57
|
-
requests) go to the mailing list: mailto:
|
56
|
+
requests) go to the mailing list: mailto:http_spew-public@bogomips.org
|
58
57
|
|
59
|
-
Mailing list archives
|
58
|
+
Mailing list archives may be viewed and downloaded here:
|
60
59
|
|
61
|
-
|
60
|
+
https://bogomips.org/http_spew-public/
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
require "./test/helper"
|
3
|
+
require "benchmark"
|
4
|
+
|
5
|
+
class TestBMContentMD5 < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@addr, @port, @srv = start_server("./test/content-md5.ru", 1)
|
8
|
+
@sockaddr = Socket.pack_sockaddr_in(@port, @addr)
|
9
|
+
@env = {
|
10
|
+
"REQUEST_METHOD" => "PUT",
|
11
|
+
"REQUEST_URI" => "/",
|
12
|
+
"HTTP_HOST" => "example.com",
|
13
|
+
}
|
14
|
+
@tmpfiles = []
|
15
|
+
@bs = ENV['bs'] ? ENV['bs'].to_i : 1024 * 1024
|
16
|
+
@count = ENV['count'] ? ENV['count'].to_i : 1000
|
17
|
+
@cmd = %w(dd if=/dev/zero)
|
18
|
+
@cmd << "bs=#@bs"
|
19
|
+
@cmd << "count=#@count"
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
Process.kill(:QUIT, @srv)
|
24
|
+
Process.waitpid2(@srv)
|
25
|
+
@tmpfiles.each { |tmp| tmp.closed? or tmp.close! }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_upload_with_md5
|
29
|
+
rd, wr = IO.pipe
|
30
|
+
pid = fork do
|
31
|
+
$stdout.reopen(wr)
|
32
|
+
rd.close
|
33
|
+
wr.close
|
34
|
+
exec(*@cmd)
|
35
|
+
end
|
36
|
+
wr.close
|
37
|
+
@env["CONTENT_LENGTH"] = (@bs * @count).to_s
|
38
|
+
@env["rack.input"] = rd
|
39
|
+
input = HTTP_Spew::ContentMD5.new(@env)
|
40
|
+
assert_nil @env["CONTENT_LENGTH"]
|
41
|
+
assert_equal "chunked", @env["HTTP_TRANSFER_ENCODING"]
|
42
|
+
req = HTTP_Spew::Request.new(@env, input, @sockaddr)
|
43
|
+
rv = nil
|
44
|
+
res = Benchmark.measure do
|
45
|
+
rv = req.run(100000)
|
46
|
+
end
|
47
|
+
assert_equal 200, rv[0].to_i
|
48
|
+
pid, status = Process.waitpid2(pid)
|
49
|
+
assert status.success?
|
50
|
+
p res
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "./test/helper"
|
2
|
+
require "benchmark"
|
3
|
+
|
4
|
+
class TestBMContentMD5InputSpray < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@nr = 4
|
7
|
+
@addr, @port, @srv = start_server("./test/content-md5.ru", @nr)
|
8
|
+
@sockaddr = Socket.pack_sockaddr_in(@port, @addr)
|
9
|
+
@env = {
|
10
|
+
"REQUEST_METHOD" => "PUT",
|
11
|
+
"REQUEST_URI" => "/",
|
12
|
+
"HTTP_HOST" => "example.com",
|
13
|
+
}
|
14
|
+
@tmpfiles = []
|
15
|
+
@bs = ENV['bs'] ? ENV['bs'].to_i : 1024 * 1024
|
16
|
+
@count = ENV['count'] ? ENV['count'].to_i : 1000
|
17
|
+
@cmd = %w(dd if=/dev/zero)
|
18
|
+
@cmd << "bs=#@bs"
|
19
|
+
@cmd << "count=#@count"
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
Process.kill(:QUIT, @srv)
|
24
|
+
Process.waitpid2(@srv)
|
25
|
+
@tmpfiles.each { |tmp| tmp.closed? or tmp.close! }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_spray_with_md5
|
29
|
+
rd, wr = IO.pipe
|
30
|
+
pid = fork do
|
31
|
+
$stdout.reopen(wr)
|
32
|
+
rd.close
|
33
|
+
wr.close
|
34
|
+
exec(*@cmd)
|
35
|
+
end
|
36
|
+
wr.close
|
37
|
+
@env["CONTENT_LENGTH"] = (@bs * @count).to_s
|
38
|
+
@env["rack.input"] = rd
|
39
|
+
input = HTTP_Spew::ContentMD5.new(@env)
|
40
|
+
sprayer = HTTP_Spew::InputSpray.new(@env, @nr, input)
|
41
|
+
assert_nil @env["CONTENT_LENGTH"]
|
42
|
+
assert_equal "chunked", @env["HTTP_TRANSFER_ENCODING"]
|
43
|
+
reqs = sprayer.readers.map do |md5_input|
|
44
|
+
HTTP_Spew::Request.new(@env, md5_input, @sockaddr)
|
45
|
+
end
|
46
|
+
assert_equal @nr, reqs.size
|
47
|
+
rv = nil
|
48
|
+
res = Benchmark.measure do
|
49
|
+
rv = HTTP_Spew.wait_mt reqs.size, reqs, 3600
|
50
|
+
end
|
51
|
+
assert_equal @nr, rv.size
|
52
|
+
rv.each do |resp|
|
53
|
+
assert_equal 200, resp.response[0].to_i
|
54
|
+
end
|
55
|
+
pid, status = Process.waitpid2(pid)
|
56
|
+
assert status.success?
|
57
|
+
p res
|
58
|
+
end
|
59
|
+
end
|
data/http_spew.gemspec
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
ENV["VERSION"] or abort "VERSION= must be specified"
|
2
2
|
manifest = File.readlines('.manifest').map! { |x| x.chomp! }
|
3
|
-
require '
|
4
|
-
extend
|
3
|
+
require 'olddoc'
|
4
|
+
extend Olddoc::Gemspec
|
5
5
|
name, summary, title = readme_metadata
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = %q{http_spew}
|
9
9
|
s.version = ENV["VERSION"].dup
|
10
|
-
s.authors = ["
|
11
|
-
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
10
|
+
s.authors = ["kcar hackers"]
|
12
11
|
s.description = readme_description
|
13
|
-
s.email = %q{
|
12
|
+
s.email = %q{kcar@bogomips.org}
|
14
13
|
s.extra_rdoc_files = extra_rdoc_files(manifest)
|
15
14
|
s.files = manifest
|
16
|
-
s.homepage =
|
15
|
+
s.homepage = Olddoc.config['rdoc_url']
|
17
16
|
s.summary = summary
|
18
|
-
s.rdoc_options = rdoc_options
|
19
|
-
s.rubyforge_project = %q{rainbows}
|
20
17
|
s.test_files = Dir["test/test_*.rb"]
|
21
|
-
s.add_dependency(%q<kcar>, "~> 0.3")
|
18
|
+
s.add_dependency(%q<kcar>, [ "~> 0.3", ">= 0.3.1"])
|
22
19
|
s.add_dependency(%q<kgio>, "~> 2.6")
|
23
|
-
s.add_development_dependency(%q<
|
20
|
+
s.add_development_dependency(%q<olddoc>, "~> 1.0")
|
21
|
+
s.required_ruby_version = '>= 2.1'
|
22
|
+
s.licenses = %w(GPL-2.0+)
|
24
23
|
end
|
@@ -41,11 +41,11 @@ module HTTP_Spew::ClassMethods
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def with_timeout(t)
|
44
|
-
t0 =
|
44
|
+
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
45
45
|
yield
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
ensure
|
47
|
+
t[0] -= Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
|
48
|
+
t[0] = 0.0 if t[0] < 0
|
49
49
|
end
|
50
50
|
|
51
51
|
# Returns an array of requests that are complete, including those
|
@@ -60,7 +60,7 @@ module HTTP_Spew::ClassMethods
|
|
60
60
|
active << Thread.new do
|
61
61
|
begin
|
62
62
|
rv = req.run(timeout)
|
63
|
-
w.write([ i ].pack("v"))
|
63
|
+
w.write([ i ].pack("v".freeze))
|
64
64
|
rv
|
65
65
|
rescue => err
|
66
66
|
err
|
@@ -69,7 +69,7 @@ module HTTP_Spew::ClassMethods
|
|
69
69
|
end
|
70
70
|
begin
|
71
71
|
with_timeout(t) { r.kgio_wait_readable(t[0]) }
|
72
|
-
req_idx = r.read(2).unpack("v")[0]
|
72
|
+
req_idx = r.read(2).unpack("v".freeze)[0]
|
73
73
|
thr = active[req_idx]
|
74
74
|
with_timeout(t) { thr.join(t[0]) }
|
75
75
|
rv = thr.value
|
@@ -7,17 +7,16 @@ class HTTP_Spew::ContentMD5
|
|
7
7
|
attr_reader :content_md5
|
8
8
|
attr_reader :bytes_digested
|
9
9
|
|
10
|
-
CRLF = "\r\n" # :nodoc:
|
11
|
-
|
12
10
|
def initialize(env, input = env["rack.input"])
|
13
11
|
if trailer = env["HTTP_TRAILER"]
|
14
12
|
unless trailer.split(/\s*,\s*/).grep(/\AContent-MD5\z/i)[0]
|
15
|
-
trailer << (trailer.empty? ? "Content-MD5"
|
13
|
+
trailer << (trailer.empty? ? "Content-MD5".freeze
|
14
|
+
: ",Content-MD5".freeze)
|
16
15
|
end
|
17
16
|
else
|
18
|
-
env["HTTP_TRAILER"] = "Content-MD5"
|
17
|
+
env["HTTP_TRAILER"] = "Content-MD5".freeze
|
19
18
|
end
|
20
|
-
env["HTTP_TRANSFER_ENCODING"] = "chunked"
|
19
|
+
env["HTTP_TRANSFER_ENCODING"] = "chunked".freeze
|
21
20
|
@to_io, wr = HTTP_Spew::ChunkyPipe.new
|
22
21
|
expect_md5 = env.delete("HTTP_CONTENT_MD5")
|
23
22
|
expect_len = env.delete("CONTENT_LENGTH")
|
@@ -41,7 +40,7 @@ class HTTP_Spew::ContentMD5
|
|
41
40
|
@bytes_digested += n
|
42
41
|
wr.write("#{n.to_s(16)}\r\n")
|
43
42
|
digest.update(buf)
|
44
|
-
wr.write(buf <<
|
43
|
+
wr.write(buf << "\r\n".freeze)
|
45
44
|
end while input.read(0x4000, buf)
|
46
45
|
end
|
47
46
|
if expect_len && expect_len.to_i != @bytes_digested
|
data/lib/http_spew/headers.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
module HTTP_Spew::Headers
|
3
|
-
# :stopdoc:
|
4
|
-
REQUEST_METHOD = "REQUEST_METHOD"
|
5
|
-
REQUEST_URI = "REQUEST_URI"
|
6
|
-
CRLF = "\r\n"
|
7
|
-
QUERY_STRING = "QUERY_STRING"
|
8
|
-
PATH_INFO = "PATH_INFO"
|
9
|
-
CONTENT_TYPE = "CONTENT_TYPE" # specified by Rack to be !/^HTTP_/
|
10
|
-
# :startdoc:
|
11
3
|
|
12
4
|
# regenerates the request_uri from a Rack +env+
|
13
5
|
def request_uri(env)
|
14
|
-
qs = env[QUERY_STRING]
|
15
|
-
qs.size == 0 ? env[PATH_INFO] : "#{env[PATH_INFO]}?#{qs}"
|
6
|
+
qs = env['QUERY_STRING']
|
7
|
+
qs.size == 0 ? env['PATH_INFO'] : "#{env['PATH_INFO']}?#{qs}"
|
16
8
|
end
|
17
9
|
module_function :request_uri
|
18
10
|
|
@@ -27,26 +19,25 @@ module HTTP_Spew::Headers
|
|
27
19
|
#
|
28
20
|
# buf, input = env_to_headers(env, input)
|
29
21
|
def env_to_headers(env, input)
|
30
|
-
req = "#{env[REQUEST_METHOD]} " \
|
31
|
-
"#{env[REQUEST_URI] || request_uri(env)} HTTP/1.1\r\n" \
|
22
|
+
req = "#{env['REQUEST_METHOD']} " \
|
23
|
+
"#{env['REQUEST_URI'] || request_uri(env)} HTTP/1.1\r\n" \
|
32
24
|
"Connection: close\r\n"
|
33
|
-
uscore, dash = "_", "-"
|
34
25
|
env.each do |key,value|
|
35
26
|
%r{\AHTTP_(\w+)\z} =~ key or next
|
36
27
|
key = $1
|
37
28
|
%r{\A(?:VERSION|EXPECT|TRANSFER_ENCODING|CONNECTION|KEEP_ALIVE)\z}x =~
|
38
29
|
key and next
|
39
30
|
|
40
|
-
key.tr!(
|
31
|
+
key.tr!('_'.freeze, '-'.freeze)
|
41
32
|
req << "#{key}: #{value}\r\n"
|
42
33
|
end
|
43
34
|
if input
|
44
35
|
req << (input.respond_to?(:size) ?
|
45
36
|
"Content-Length: #{input.size}\r\n" :
|
46
|
-
"Transfer-Encoding: chunked\r\n")
|
47
|
-
ct = env[CONTENT_TYPE] and req << "Content-Type: #{ct}\r\n"
|
37
|
+
"Transfer-Encoding: chunked\r\n".freeze)
|
38
|
+
ct = env['CONTENT_TYPE'] and req << "Content-Type: #{ct}\r\n"
|
48
39
|
end
|
49
|
-
req <<
|
40
|
+
req << "\r\n".freeze
|
50
41
|
String === input ? (req << input) : [ req, input ]
|
51
42
|
end
|
52
43
|
module_function :env_to_headers
|
data/lib/http_spew/request.rb
CHANGED
@@ -55,17 +55,17 @@ class HTTP_Spew::Request
|
|
55
55
|
# returns a 3-element Rack response array on successful completion
|
56
56
|
# returns an Exception if one was raised
|
57
57
|
def run(timeout)
|
58
|
-
t0 =
|
58
|
+
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
59
59
|
buf, @buf = @buf, nil # make inspect nicer
|
60
60
|
@to_io.write(buf)
|
61
61
|
if @input
|
62
62
|
@to_io.write(buf) while @input.read(0x4000, buf)
|
63
63
|
end
|
64
|
-
timeout -= (
|
64
|
+
timeout -= (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0)
|
65
65
|
while :wait_readable == (rv = read_response) && timeout >= 0.0
|
66
|
-
t0 =
|
66
|
+
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
67
67
|
@to_io.kgio_wait_readable(timeout) if timeout > 0.0
|
68
|
-
timeout -= (
|
68
|
+
timeout -= (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0)
|
69
69
|
end
|
70
70
|
rv
|
71
71
|
rescue => e
|
data/lib/http_spew/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
|
-
HTTP_Spew.const_set :VERSION, "0.
|
2
|
+
HTTP_Spew.const_set :VERSION, "0.5.0".freeze
|
data/lib/http_spew.rb
CHANGED
@@ -8,20 +8,20 @@ module HTTP_Spew
|
|
8
8
|
autoload :HitNRun, "http_spew/hit_n_run"
|
9
9
|
autoload :InputSpray, "http_spew/input_spray"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
Error = Class.new(RuntimeError)
|
12
|
+
TimeoutError = Class.new(Error)
|
13
|
+
ConnectionReset = Class.new(Error)
|
14
|
+
RequestError = Class.new(Error)
|
15
|
+
UnexpectedResponse = Class.new(RequestError)
|
16
|
+
ChecksumError = Class.new(Error)
|
17
|
+
LengthError = Class.new(Error)
|
18
|
+
NoWritersError = Class.new(Error)
|
19
|
+
EOF = Class.new(EOFError)
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
require_relative "http_spew/version"
|
22
|
+
require_relative "http_spew/headers"
|
23
|
+
require_relative "http_spew/request"
|
24
|
+
require_relative "http_spew/class_methods"
|
25
25
|
|
26
26
|
extend HTTP_Spew::ClassMethods
|
27
27
|
end
|
data/pkg.mk
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
RUBY = ruby
|
2
2
|
RAKE = rake
|
3
3
|
RSYNC = rsync
|
4
|
-
|
4
|
+
OLDDOC = olddoc
|
5
|
+
RDOC = rdoc
|
5
6
|
|
6
7
|
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
|
7
8
|
@./GIT-VERSION-GEN
|
@@ -12,14 +13,6 @@ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
|
|
12
13
|
RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
|
13
14
|
lib := lib
|
14
15
|
|
15
|
-
ifeq ($(shell test -f script/isolate_for_tests && echo t),t)
|
16
|
-
isolate_libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/isolate.mk
|
17
|
-
$(isolate_libs): script/isolate_for_tests
|
18
|
-
@$(RUBY) script/isolate_for_tests
|
19
|
-
-include $(isolate_libs)
|
20
|
-
lib := $(lib):$(ISOLATE_LIBS)
|
21
|
-
endif
|
22
|
-
|
23
16
|
ext := $(firstword $(wildcard ext/*))
|
24
17
|
ifneq ($(ext),)
|
25
18
|
ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
|
@@ -36,7 +29,7 @@ $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
|
|
36
29
|
install -m 644 $< $@
|
37
30
|
$(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
|
38
31
|
$(RM) -f $(@D)/*.o
|
39
|
-
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb
|
32
|
+
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
|
40
33
|
ext_sfx := _ext.$(DLEXT)
|
41
34
|
ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
|
42
35
|
$(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
|
@@ -48,10 +41,10 @@ else
|
|
48
41
|
build:
|
49
42
|
endif
|
50
43
|
|
51
|
-
pkg_extra += GIT-VERSION-FILE NEWS
|
52
|
-
|
53
|
-
$(
|
54
|
-
|
44
|
+
pkg_extra += GIT-VERSION-FILE NEWS LATEST
|
45
|
+
NEWS: GIT-VERSION-FILE .olddoc.yml
|
46
|
+
$(OLDDOC) prepare
|
47
|
+
LATEST: NEWS
|
55
48
|
|
56
49
|
manifest:
|
57
50
|
$(RM) .manifest
|
@@ -63,28 +56,20 @@ manifest:
|
|
63
56
|
cmp $@+ $@ || mv $@+ $@
|
64
57
|
$(RM) $@+
|
65
58
|
|
66
|
-
doc:: .document .
|
59
|
+
doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
|
67
60
|
-find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
|
68
61
|
-find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
|
69
62
|
$(RM) -r doc
|
70
|
-
$(
|
71
|
-
|
72
|
-
|
63
|
+
$(RDOC) -f oldweb
|
64
|
+
$(OLDDOC) merge
|
65
|
+
if test -f COPYING; then install -m644 COPYING doc/COPYING; fi
|
66
|
+
install -m644 NEWS doc/NEWS
|
67
|
+
install -m644 NEWS.atom.xml doc/NEWS.atom.xml
|
68
|
+
install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
|
73
69
|
|
74
70
|
ifneq ($(VERSION),)
|
75
71
|
pkggem := pkg/$(rfpackage)-$(VERSION).gem
|
76
72
|
pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
|
77
|
-
release_notes := release_notes-$(VERSION)
|
78
|
-
release_changes := release_changes-$(VERSION)
|
79
|
-
|
80
|
-
release-notes: $(release_notes)
|
81
|
-
release-changes: $(release_changes)
|
82
|
-
$(release_changes):
|
83
|
-
$(WRONGDOC) release_changes > $@+
|
84
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
85
|
-
$(release_notes):
|
86
|
-
$(WRONGDOC) release_notes > $@+
|
87
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
88
73
|
|
89
74
|
# ensures we're actually on the tagged $(VERSION), only used for release
|
90
75
|
verify:
|
@@ -120,31 +105,18 @@ $(pkgtgz): manifest fix-perms
|
|
120
105
|
|
121
106
|
package: $(pkgtgz) $(pkggem)
|
122
107
|
|
123
|
-
|
124
|
-
# make tgz release on RubyForge
|
125
|
-
@echo rubyforge add_release -f \
|
126
|
-
-n $(release_notes) -a $(release_changes) \
|
127
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
|
128
|
-
@echo gem push $(pkggem)
|
129
|
-
@echo rubyforge add_file \
|
130
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkggem)
|
131
|
-
release:: verify package $(release_notes) $(release_changes)
|
132
|
-
# make tgz release on RubyForge
|
133
|
-
rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
|
134
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
|
108
|
+
release:: verify package
|
135
109
|
# push gem to RubyGems.org
|
136
110
|
gem push $(pkggem)
|
137
|
-
# in case of gem downloads from RubyForge releases page
|
138
|
-
rubyforge add_file \
|
139
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkggem)
|
140
111
|
else
|
141
112
|
gem install-gem: GIT-VERSION-FILE
|
142
113
|
$(MAKE) $@ VERSION=$(GIT_VERSION)
|
143
114
|
endif
|
144
115
|
|
145
|
-
all::
|
116
|
+
all:: check
|
146
117
|
test_units := $(wildcard test/test_*.rb)
|
147
|
-
test:
|
118
|
+
test: check
|
119
|
+
check: test-unit
|
148
120
|
test-unit: $(test_units)
|
149
121
|
$(test_units): build
|
150
122
|
$(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
|
@@ -154,8 +126,6 @@ ifneq ($(RSYNC_DEST),)
|
|
154
126
|
publish_doc:
|
155
127
|
-git set-file-times
|
156
128
|
$(MAKE) doc
|
157
|
-
find doc/images -type f | \
|
158
|
-
TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
|
159
129
|
$(MAKE) doc_gz
|
160
130
|
$(RSYNC) -av doc/ $(RSYNC_DEST)/
|
161
131
|
git ls-files | xargs touch
|
@@ -163,13 +133,18 @@ endif
|
|
163
133
|
|
164
134
|
# Create gzip variants of the same timestamp as the original so nginx
|
165
135
|
# "gzip_static on" can serve the gzipped versions directly.
|
166
|
-
doc_gz: docs = $(shell find doc -type f ! -regex '
|
136
|
+
doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
|
167
137
|
doc_gz:
|
168
138
|
for i in $(docs); do \
|
169
139
|
gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
|
170
140
|
check-warnings:
|
171
|
-
@(for i in $$(git ls-files '*.rb'|grep -v '^setup\.rb$$'); \
|
141
|
+
@(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
|
172
142
|
do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
|
173
143
|
|
174
|
-
|
144
|
+
ifneq ($(PLACEHOLDERS),)
|
145
|
+
$(PLACEHOLDERS):
|
146
|
+
echo olddoc_placeholder > $@
|
147
|
+
endif
|
148
|
+
|
149
|
+
.PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
|
175
150
|
.PHONY: check-warnings
|
data/test/helper.rb
CHANGED
@@ -10,6 +10,7 @@ require "rack"
|
|
10
10
|
require "tempfile"
|
11
11
|
$-w = true
|
12
12
|
require "http_spew"
|
13
|
+
HAVE_UNICORN = `which unicorn 2>/dev/null`.size > 0
|
13
14
|
|
14
15
|
def start_server(config, worker_processes = 4, rewindable_input = false)
|
15
16
|
ENV["RACK_ENV"] = "deployment"
|
@@ -32,7 +33,8 @@ EOF
|
|
32
33
|
cfg.flush
|
33
34
|
pid = fork do
|
34
35
|
ENV["UNICORN_FD"] = sock.fileno.to_s
|
35
|
-
|
36
|
+
redirect = { sock => sock } if RUBY_VERSION.to_f >= 2.0
|
37
|
+
exec "unicorn", "-l#{addr}:#{port}", "-c#{cfg.path}", config, redirect
|
36
38
|
end
|
37
39
|
File.open(fifo_path).close
|
38
40
|
File.unlink fifo_path
|
data/test/test_content_md5.rb
CHANGED
data/test/test_hit_n_run.rb
CHANGED
@@ -60,9 +60,9 @@ class TestInputSprayWithMD5 < Test::Unit::TestCase
|
|
60
60
|
HTTP_Spew::Request.new(@env, md5_input, @sockaddr)
|
61
61
|
end
|
62
62
|
assert_equal @nr, reqs.size
|
63
|
-
t0 =
|
63
|
+
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
64
64
|
rv = HTTP_Spew.wait_mt reqs.size, reqs, 3600
|
65
|
-
elapsed =
|
65
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
|
66
66
|
assert(elapsed <= 30, "took too long: #{elapsed}s")
|
67
67
|
assert_equal @nr, rv.size
|
68
68
|
rv.each { |r|
|
@@ -104,4 +104,4 @@ class TestInputSprayWithMD5 < Test::Unit::TestCase
|
|
104
104
|
assert_equal expect_md5, input.content_md5
|
105
105
|
assert_equal 123 * 8 * 1021 * 13, input.bytes_digested
|
106
106
|
end
|
107
|
-
end
|
107
|
+
end if HAVE_UNICORN
|