hatetepe 0.5.2 → 0.6.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/.yardopts +1 -0
- data/Gemfile +9 -4
- data/Gemfile.devtools +55 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -192
- data/Rakefile +3 -2
- data/bin/hatetepe +35 -2
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +103 -0
- data/config/rubocop.yml +58 -0
- data/config/yardstick.yml +2 -0
- data/hatetepe.gemspec +23 -27
- data/lib/hatetepe/client/keep_alive.rb +59 -0
- data/lib/hatetepe/client/timeouts.rb +19 -0
- data/lib/hatetepe/client.rb +54 -302
- data/lib/hatetepe/connection/eventmachine.rb +61 -0
- data/lib/hatetepe/connection/status.rb +28 -0
- data/lib/hatetepe/errors.rb +7 -0
- data/lib/hatetepe/promise.rb +86 -0
- data/lib/hatetepe/request.rb +15 -39
- data/lib/hatetepe/response.rb +82 -22
- data/lib/hatetepe/serializer/encoding.rb +58 -0
- data/lib/hatetepe/serializer.rb +61 -0
- data/lib/hatetepe/server/keep_alive.rb +53 -13
- data/lib/hatetepe/server/timeouts.rb +17 -0
- data/lib/hatetepe/server.rb +37 -85
- data/lib/hatetepe/support/handlers.rb +19 -0
- data/lib/hatetepe/support/keep_alive.rb +14 -0
- data/lib/hatetepe/support/message.rb +40 -0
- data/lib/hatetepe/version.rb +3 -1
- data/lib/hatetepe.rb +29 -7
- data/spec/integration/error_handling_spec.rb +7 -0
- data/spec/integration/keep_alive_spec.rb +106 -0
- data/spec/integration/smoke_spec.rb +21 -0
- data/spec/integration/streaming_spec.rb +61 -0
- data/spec/integration/timeouts_spec.rb +82 -0
- data/spec/shared/integration/server_client_pair.rb +26 -0
- data/spec/spec_helper.rb +41 -10
- data/spec/support/handler.rb +55 -0
- data/spec/support/helper.rb +74 -0
- data/spec/unit/client_spec.rb +115 -156
- data/spec/unit/connection/eventmachine_spec.rb +146 -0
- data/spec/unit/request_spec.rb +35 -0
- data/spec/unit/response_spec.rb +42 -0
- data/spec/unit/server_spec.rb +65 -100
- data/spec/unit/support/keep_alive_spec.rb +52 -0
- data/spec/unit/support/message_spec.rb +41 -0
- metadata +68 -103
- data/Gemfile.lock +0 -46
- data/LICENSE +0 -19
- data/Procfile +0 -1
- data/config.ru +0 -7
- data/examples/parallel_requests.rb +0 -32
- data/lib/hatetepe/body.rb +0 -182
- data/lib/hatetepe/builder.rb +0 -171
- data/lib/hatetepe/cli.rb +0 -61
- data/lib/hatetepe/connection.rb +0 -73
- data/lib/hatetepe/events.rb +0 -35
- data/lib/hatetepe/message.rb +0 -13
- data/lib/hatetepe/parser.rb +0 -83
- data/lib/hatetepe/server/pipeline.rb +0 -20
- data/lib/hatetepe/server/rack_app.rb +0 -39
- data/lib/rack/handler/hatetepe.rb +0 -33
- data/spec/integration/cli/start_spec.rb +0 -113
- data/spec/integration/client/keep_alive_spec.rb +0 -23
- data/spec/integration/client/timeout_spec.rb +0 -97
- data/spec/integration/server/keep_alive_spec.rb +0 -27
- data/spec/integration/server/timeout_spec.rb +0 -51
- data/spec/unit/body_spec.rb +0 -205
- data/spec/unit/builder_spec.rb +0 -372
- data/spec/unit/connection_spec.rb +0 -62
- data/spec/unit/events_spec.rb +0 -96
- data/spec/unit/parser_spec.rb +0 -209
- data/spec/unit/rack_handler_spec.rb +0 -60
data/spec/unit/server_spec.rb
CHANGED
@@ -1,127 +1,92 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
4
|
-
require "hatetepe/server"
|
5
|
-
require "rack/lint"
|
3
|
+
require 'spec_helper'
|
6
4
|
|
7
|
-
describe Hatetepe::Server
|
8
|
-
|
9
|
-
it "starts a server that listens on the supplied interface and port"
|
10
|
-
it "passes the config to incoming connections"
|
11
|
-
it "uses the passed block as app if any was passed"
|
12
|
-
end
|
5
|
+
describe Hatetepe::Server do
|
6
|
+
let(:server) { described_class.new(config, connection) }
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
let(:config) do
|
9
|
+
{ address: localhost, port: random_port, handlers: [handler_class] }
|
10
|
+
end
|
11
|
+
let(:connection) do
|
12
|
+
double('connection', parse: nil,
|
13
|
+
closed: double('closed', then: nil),
|
14
|
+
serialize: nil,
|
15
|
+
close: nil)
|
17
16
|
end
|
17
|
+
let(:handler_class) { double('handler_class', new: handler) }
|
18
|
+
let(:handler) { double('handler', post_init: nil, respond: nil) }
|
18
19
|
|
19
|
-
describe
|
20
|
-
|
20
|
+
describe '.start' do
|
21
|
+
specify { pending }
|
21
22
|
end
|
22
23
|
|
23
|
-
describe
|
24
|
-
|
25
|
-
Object.new.tap do |s|
|
26
|
-
s.extend Hatetepe::Server
|
27
|
-
s.stub({
|
28
|
-
:config => {
|
29
|
-
:host => "127.0.5.1",
|
30
|
-
:port => 3000,
|
31
|
-
:app => app
|
32
|
-
},
|
33
|
-
:send_data => nil
|
34
|
-
})
|
35
|
-
s.stub(:comm_inactivity_timeout=)
|
36
|
-
s.stub(:close_connection)
|
37
|
-
s.post_init
|
38
|
-
end
|
39
|
-
end
|
24
|
+
describe '#initialize' do
|
25
|
+
subject! { server }
|
40
26
|
|
41
|
-
|
42
|
-
double("app", :call => nil)
|
43
|
-
end
|
27
|
+
its(:config) { should be(config) }
|
44
28
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
"",
|
51
|
-
"Hello, world!"
|
52
|
-
].join("\r\n")
|
29
|
+
it 'sets up connection' do
|
30
|
+
expect(connection).to have_received(:parse)
|
31
|
+
.with(server.method(:serve))
|
32
|
+
expect(connection.closed).to have_received(:then)
|
33
|
+
.with(server.method(:shutdown))
|
53
34
|
end
|
54
35
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"Transfer-Encoding: chunked",
|
60
|
-
"",
|
61
|
-
"b",
|
62
|
-
"Mmh, nöö.",
|
63
|
-
"0",
|
64
|
-
"",
|
65
|
-
""
|
66
|
-
].join("\r\n")
|
36
|
+
it 'sets up handlers' do
|
37
|
+
expect(handler_class).to have_received(:new)
|
38
|
+
.with(config, server, connection)
|
39
|
+
expect(handler).to have_received(:post_init)
|
67
40
|
end
|
41
|
+
end
|
68
42
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
env["REQUEST_METHOD"].should == "POST"
|
73
|
-
env["REQUEST_URI"].should == "/foo/bar?key=value"
|
74
|
-
env["HTTP_HOST"].should == "themachine.local"
|
75
|
-
env["rack.input"].read.should == "Hello, world!"
|
76
|
-
[ 200, {}, [] ]
|
77
|
-
end
|
78
|
-
|
79
|
-
subject.receive_data(http_request)
|
80
|
-
end
|
43
|
+
describe '#serve' do
|
44
|
+
let(:request) { default_request }
|
45
|
+
let(:response) { default_response }
|
81
46
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
47
|
+
before do
|
48
|
+
allow(server).to receive(:respond)
|
49
|
+
allow(handler).to receive(:serve) { @fiber = Fiber.current }
|
50
|
+
end
|
86
51
|
|
87
|
-
|
88
|
-
subject.stub(:send_data) {|data| sent << data }
|
52
|
+
subject! { server.serve(request) }
|
89
53
|
|
90
|
-
|
91
|
-
|
54
|
+
it 'sets up correlation' do
|
55
|
+
request.served.fulfill(response)
|
56
|
+
tick
|
57
|
+
expect(server).to have_received(:respond).with(request, response)
|
92
58
|
end
|
93
59
|
|
94
|
-
it
|
95
|
-
|
96
|
-
|
97
|
-
response = [ 403, { "Content-Type" => "text/plain" }, [ "Mmh, nöö." ] ]
|
98
|
-
env["async.callback"].call(response)
|
99
|
-
end
|
100
|
-
[ -1, {}, [] ]
|
101
|
-
end
|
102
|
-
|
103
|
-
sent = ""
|
104
|
-
subject.stub(:send_data) {|data| sent << data }
|
105
|
-
|
106
|
-
subject.receive_data(http_request)
|
107
|
-
EM::Synchrony.sleep(0.55)
|
108
|
-
sent.should == http_response
|
60
|
+
it 'notifies the handlers' do
|
61
|
+
expect(handler).to have_received(:serve).with(request)
|
62
|
+
expect(@fiber).not_to be(Fiber.current)
|
109
63
|
end
|
110
64
|
end
|
111
|
-
end
|
112
65
|
|
113
|
-
describe
|
114
|
-
|
66
|
+
describe '#respond' do
|
67
|
+
let(:request) { default_request }
|
68
|
+
let(:response) { default_response }
|
115
69
|
|
116
|
-
|
70
|
+
subject! { server.respond(request, response) }
|
117
71
|
|
118
|
-
|
72
|
+
it 'writes response to underlying connection' do
|
73
|
+
expect(connection).to have_received(:serialize).with(response)
|
74
|
+
end
|
119
75
|
|
120
|
-
|
121
|
-
|
76
|
+
it 'notifies the handlers' do
|
77
|
+
expect(handler).to have_received(:respond).with(request, response)
|
78
|
+
end
|
79
|
+
end
|
122
80
|
|
123
|
-
describe
|
124
|
-
|
81
|
+
describe '#close' do
|
82
|
+
subject! { server.close }
|
125
83
|
|
126
|
-
|
84
|
+
it 'closes the underlying connection' do
|
85
|
+
expect(connection).to have_received(:close)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#teardown' do
|
90
|
+
specify { pending }
|
91
|
+
end
|
127
92
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Hatetepe::Support::KeepAlive, '#close_connection?' do
|
6
|
+
let(:object) { double.extend(Hatetepe::Support::KeepAlive) }
|
7
|
+
let(:subject) { object.close_connection?(http_version, header) }
|
8
|
+
|
9
|
+
describe 'with HTTP/1.0' do
|
10
|
+
let(:http_version) { 1.0 }
|
11
|
+
|
12
|
+
describe 'and no header' do
|
13
|
+
let(:header) { nil }
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'and Connection: close' do
|
19
|
+
let(:header) { 'close' }
|
20
|
+
|
21
|
+
it { should be(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'and Connection: keep-alive' do
|
25
|
+
let(:header) { 'keep-alive' }
|
26
|
+
|
27
|
+
it { should be(false) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'with HTTP/1.1' do
|
32
|
+
let(:http_version) { 1.1 }
|
33
|
+
|
34
|
+
describe 'and no header' do
|
35
|
+
let(:header) { nil }
|
36
|
+
|
37
|
+
it { should be(false) }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'and Connection: close' do
|
41
|
+
let(:header) { 'close' }
|
42
|
+
|
43
|
+
it { should be(true) }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'and Connection: keep-alive' do
|
47
|
+
let(:header) { 'keep-alive' }
|
48
|
+
|
49
|
+
it { should be(false) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Hatetepe::Support::Message do
|
6
|
+
describe '.build', 'given a parser holding a request' do
|
7
|
+
let(:parser) do
|
8
|
+
Struct.new(:http_method, :request_url, :headers, :http_version)
|
9
|
+
.new('GET', '/', { 'Key' => 'value' }, [1, 1])
|
10
|
+
end
|
11
|
+
let(:args) { [:get, '/', { 'Key' => 'value' }] }
|
12
|
+
let(:request) { double }
|
13
|
+
|
14
|
+
subject { Hatetepe::Support::Message.build(parser) }
|
15
|
+
|
16
|
+
it 'returns a Request object' do
|
17
|
+
expect(Hatetepe::Request)
|
18
|
+
.to receive(:new).with(*args).and_return(request)
|
19
|
+
expect(request).to receive(:http_version=).with(1.1)
|
20
|
+
expect(subject).to be(request)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.build', 'given a parser holding a response' do
|
25
|
+
let(:parser) do
|
26
|
+
Struct.new(:http_method, :status_code, :headers, :http_version)
|
27
|
+
.new(nil, 200, { 'Key' => 'value' }, [1, 0])
|
28
|
+
end
|
29
|
+
let(:args) { [200, { 'Key' => 'value' }] }
|
30
|
+
let(:response) { double }
|
31
|
+
|
32
|
+
subject { Hatetepe::Support::Message.build(parser) }
|
33
|
+
|
34
|
+
it 'returns a Response object' do
|
35
|
+
expect(Hatetepe::Response)
|
36
|
+
.to receive(:new).with(*args).and_return(response)
|
37
|
+
expect(response).to receive(:http_version=).with(1.0)
|
38
|
+
expect(subject).to be(response)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,66 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatetepe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lars Gierth
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: http_parser.rb
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.6.0.beta.2
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.6.0.beta.2
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: eventmachine
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 1.0.0.beta.4
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.0.0.beta.4
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: em-synchrony
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rack
|
64
16
|
requirement: !ruby/object:Gem::Requirement
|
65
17
|
none: false
|
66
18
|
requirements:
|
@@ -76,7 +28,7 @@ dependencies:
|
|
76
28
|
- !ruby/object:Gem::Version
|
77
29
|
version: '0'
|
78
30
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
31
|
+
name: http_parser.rb
|
80
32
|
requirement: !ruby/object:Gem::Requirement
|
81
33
|
none: false
|
82
34
|
requirements:
|
@@ -92,30 +44,14 @@ dependencies:
|
|
92
44
|
- !ruby/object:Gem::Version
|
93
45
|
version: '0'
|
94
46
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
47
|
+
name: promise.rb
|
96
48
|
requirement: !ruby/object:Gem::Requirement
|
97
49
|
none: false
|
98
50
|
requirements:
|
99
51
|
- - ! '>='
|
100
52
|
- !ruby/object:Gem::Version
|
101
53
|
version: '0'
|
102
|
-
type: :
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: yard
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
54
|
+
type: :runtime
|
119
55
|
prerelease: false
|
120
56
|
version_requirements: !ruby/object:Gem::Requirement
|
121
57
|
none: false
|
@@ -124,7 +60,7 @@ dependencies:
|
|
124
60
|
- !ruby/object:Gem::Version
|
125
61
|
version: '0'
|
126
62
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
63
|
+
name: rspec
|
128
64
|
requirement: !ruby/object:Gem::Requirement
|
129
65
|
none: false
|
130
66
|
requirements:
|
@@ -139,7 +75,7 @@ dependencies:
|
|
139
75
|
- - ! '>='
|
140
76
|
- !ruby/object:Gem::Version
|
141
77
|
version: '0'
|
142
|
-
description:
|
78
|
+
description: The HTTP toolkit
|
143
79
|
email:
|
144
80
|
- lars.gierth@gmail.com
|
145
81
|
executables:
|
@@ -147,49 +83,62 @@ executables:
|
|
147
83
|
extensions: []
|
148
84
|
extra_rdoc_files: []
|
149
85
|
files:
|
86
|
+
- .gitignore
|
87
|
+
- .rspec
|
88
|
+
- .travis.yml
|
89
|
+
- .yardopts
|
150
90
|
- Gemfile
|
151
|
-
- Gemfile.
|
152
|
-
- LICENSE
|
153
|
-
- Procfile
|
91
|
+
- Gemfile.devtools
|
92
|
+
- LICENSE.txt
|
154
93
|
- README.md
|
155
94
|
- Rakefile
|
156
95
|
- bin/hatetepe
|
157
|
-
- config.
|
158
|
-
-
|
96
|
+
- config/devtools.yml
|
97
|
+
- config/flay.yml
|
98
|
+
- config/flog.yml
|
99
|
+
- config/mutant.yml
|
100
|
+
- config/reek.yml
|
101
|
+
- config/rubocop.yml
|
102
|
+
- config/yardstick.yml
|
159
103
|
- hatetepe.gemspec
|
160
104
|
- lib/hatetepe.rb
|
161
|
-
- lib/hatetepe/body.rb
|
162
|
-
- lib/hatetepe/builder.rb
|
163
|
-
- lib/hatetepe/cli.rb
|
164
105
|
- lib/hatetepe/client.rb
|
165
|
-
- lib/hatetepe/
|
166
|
-
- lib/hatetepe/
|
167
|
-
- lib/hatetepe/
|
168
|
-
- lib/hatetepe/
|
106
|
+
- lib/hatetepe/client/keep_alive.rb
|
107
|
+
- lib/hatetepe/client/timeouts.rb
|
108
|
+
- lib/hatetepe/connection/eventmachine.rb
|
109
|
+
- lib/hatetepe/connection/status.rb
|
110
|
+
- lib/hatetepe/errors.rb
|
111
|
+
- lib/hatetepe/promise.rb
|
169
112
|
- lib/hatetepe/request.rb
|
170
113
|
- lib/hatetepe/response.rb
|
114
|
+
- lib/hatetepe/serializer.rb
|
115
|
+
- lib/hatetepe/serializer/encoding.rb
|
171
116
|
- lib/hatetepe/server.rb
|
172
117
|
- lib/hatetepe/server/keep_alive.rb
|
173
|
-
- lib/hatetepe/server/
|
174
|
-
- lib/hatetepe/
|
118
|
+
- lib/hatetepe/server/timeouts.rb
|
119
|
+
- lib/hatetepe/support/handlers.rb
|
120
|
+
- lib/hatetepe/support/keep_alive.rb
|
121
|
+
- lib/hatetepe/support/message.rb
|
175
122
|
- lib/hatetepe/version.rb
|
176
|
-
-
|
177
|
-
- spec/integration/
|
178
|
-
- spec/integration/
|
179
|
-
- spec/integration/
|
180
|
-
- spec/integration/
|
181
|
-
- spec/integration/
|
123
|
+
- spec/integration/error_handling_spec.rb
|
124
|
+
- spec/integration/keep_alive_spec.rb
|
125
|
+
- spec/integration/smoke_spec.rb
|
126
|
+
- spec/integration/streaming_spec.rb
|
127
|
+
- spec/integration/timeouts_spec.rb
|
128
|
+
- spec/shared/integration/server_client_pair.rb
|
182
129
|
- spec/spec_helper.rb
|
183
|
-
- spec/
|
184
|
-
- spec/
|
130
|
+
- spec/support/handler.rb
|
131
|
+
- spec/support/helper.rb
|
185
132
|
- spec/unit/client_spec.rb
|
186
|
-
- spec/unit/
|
187
|
-
- spec/unit/
|
188
|
-
- spec/unit/
|
189
|
-
- spec/unit/rack_handler_spec.rb
|
133
|
+
- spec/unit/connection/eventmachine_spec.rb
|
134
|
+
- spec/unit/request_spec.rb
|
135
|
+
- spec/unit/response_spec.rb
|
190
136
|
- spec/unit/server_spec.rb
|
137
|
+
- spec/unit/support/keep_alive_spec.rb
|
138
|
+
- spec/unit/support/message_spec.rb
|
191
139
|
homepage: https://github.com/lgierth/hatetepe
|
192
|
-
licenses:
|
140
|
+
licenses:
|
141
|
+
- MIT
|
193
142
|
post_install_message:
|
194
143
|
rdoc_options: []
|
195
144
|
require_paths:
|
@@ -203,14 +152,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
153
|
none: false
|
205
154
|
requirements:
|
206
|
-
- - ! '
|
155
|
+
- - ! '>'
|
207
156
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
157
|
+
version: 1.3.1
|
209
158
|
requirements: []
|
210
159
|
rubyforge_project:
|
211
160
|
rubygems_version: 1.8.23
|
212
161
|
signing_key:
|
213
162
|
specification_version: 3
|
214
|
-
summary:
|
215
|
-
test_files:
|
163
|
+
summary: General purpose toolkit for HTTP clients and servers
|
164
|
+
test_files:
|
165
|
+
- spec/integration/error_handling_spec.rb
|
166
|
+
- spec/integration/keep_alive_spec.rb
|
167
|
+
- spec/integration/smoke_spec.rb
|
168
|
+
- spec/integration/streaming_spec.rb
|
169
|
+
- spec/integration/timeouts_spec.rb
|
170
|
+
- spec/shared/integration/server_client_pair.rb
|
171
|
+
- spec/spec_helper.rb
|
172
|
+
- spec/support/handler.rb
|
173
|
+
- spec/support/helper.rb
|
174
|
+
- spec/unit/client_spec.rb
|
175
|
+
- spec/unit/connection/eventmachine_spec.rb
|
176
|
+
- spec/unit/request_spec.rb
|
177
|
+
- spec/unit/response_spec.rb
|
178
|
+
- spec/unit/server_spec.rb
|
179
|
+
- spec/unit/support/keep_alive_spec.rb
|
180
|
+
- spec/unit/support/message_spec.rb
|
216
181
|
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
hatetepe (0.5.1)
|
5
|
-
em-synchrony (~> 1.0)
|
6
|
-
eventmachine (~> 1.0.0.beta.4)
|
7
|
-
http_parser.rb (~> 0.6.0.beta.2)
|
8
|
-
rack
|
9
|
-
thor
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
awesome_print (1.1.0)
|
15
|
-
diff-lcs (1.2.4)
|
16
|
-
em-synchrony (1.0.3)
|
17
|
-
eventmachine (>= 1.0.0.beta.1)
|
18
|
-
eventmachine (1.0.3)
|
19
|
-
eventmachine (1.0.3-java)
|
20
|
-
http_parser.rb (0.6.0.beta.2)
|
21
|
-
http_parser.rb (0.6.0.beta.2-java)
|
22
|
-
kramdown (1.1.0)
|
23
|
-
rack (1.5.2)
|
24
|
-
rake (10.1.0)
|
25
|
-
rspec (2.14.1)
|
26
|
-
rspec-core (~> 2.14.0)
|
27
|
-
rspec-expectations (~> 2.14.0)
|
28
|
-
rspec-mocks (~> 2.14.0)
|
29
|
-
rspec-core (2.14.4)
|
30
|
-
rspec-expectations (2.14.1)
|
31
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
32
|
-
rspec-mocks (2.14.3)
|
33
|
-
thor (0.18.1)
|
34
|
-
yard (0.8.7)
|
35
|
-
|
36
|
-
PLATFORMS
|
37
|
-
java
|
38
|
-
ruby
|
39
|
-
|
40
|
-
DEPENDENCIES
|
41
|
-
awesome_print
|
42
|
-
hatetepe!
|
43
|
-
kramdown
|
44
|
-
rake
|
45
|
-
rspec
|
46
|
-
yard
|
data/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Lars Gierth
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
data/Procfile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
web: bundle exec hatetepe -p $PORT -b 0.0.0.0
|
data/config.ru
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require "hatetepe"
|
2
|
-
require "awesome_print"
|
3
|
-
|
4
|
-
EM.synchrony do
|
5
|
-
# one server
|
6
|
-
app = proc do |env|
|
7
|
-
[200, {"Content-Type" => "text/plain"}, ["Hello, world!"]]
|
8
|
-
end
|
9
|
-
Hatetepe::Server.start :host => "127.0.0.1", :port => 3123, :app => app
|
10
|
-
|
11
|
-
# two clients
|
12
|
-
clients = 2.times.map { Hatetepe::Client.start :host => "127.0.0.1", :port => 3123 }
|
13
|
-
|
14
|
-
# six requests
|
15
|
-
requests = 6.times.map do |i|
|
16
|
-
# no extra headers, empty body
|
17
|
-
req = Hatetepe::Request.new(:get, "/", {}, [])
|
18
|
-
|
19
|
-
# response status between 100 and 399
|
20
|
-
req.callback {|res| puts "request ##{i} finished with #{res.status} response" }
|
21
|
-
|
22
|
-
# response status between 400 and 599 or connection failure
|
23
|
-
req.errback {|res| puts "request ##{i} finished with #{res ? res.status : 'no'} response" }
|
24
|
-
|
25
|
-
clients[i % clients.length] << req
|
26
|
-
req
|
27
|
-
end
|
28
|
-
|
29
|
-
# Client#stop waits until all of its requests have finished
|
30
|
-
clients.map &:stop
|
31
|
-
EM.stop
|
32
|
-
end
|