hatetepe 0.6.0.pre → 0.6.0.pre.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/README.md +6 -4
- data/bin/hatetepe +4 -8
- data/config/flay.yml +2 -2
- data/config/reek.yml +15 -11
- data/lib/hatetepe.rb +1 -1
- data/lib/hatetepe/body.rb +62 -0
- data/lib/hatetepe/client.rb +34 -34
- data/lib/hatetepe/client/keep_alive.rb +4 -49
- data/lib/hatetepe/client/timeouts.rb +3 -3
- data/lib/hatetepe/connection/eventmachine.rb +7 -8
- data/lib/hatetepe/promise.rb +7 -2
- data/lib/hatetepe/request.rb +8 -10
- data/lib/hatetepe/response.rb +5 -7
- data/lib/hatetepe/serializer.rb +2 -3
- data/lib/hatetepe/serializer/encoding.rb +8 -16
- data/lib/hatetepe/server.rb +15 -10
- data/lib/hatetepe/server/keep_alive.rb +26 -31
- data/lib/hatetepe/server/timeouts.rb +3 -3
- data/lib/hatetepe/support/message.rb +25 -3
- data/lib/hatetepe/version.rb +1 -1
- data/spec/integration/keep_alive_spec.rb +18 -24
- data/spec/integration/smoke_spec.rb +2 -2
- data/spec/integration/streaming_spec.rb +9 -13
- data/spec/support/handler.rb +12 -16
- data/spec/support/helper.rb +8 -8
- data/spec/unit/client_spec.rb +25 -24
- data/spec/unit/connection/eventmachine_spec.rb +9 -8
- data/spec/unit/request_spec.rb +6 -6
- data/spec/unit/response_spec.rb +3 -3
- data/spec/unit/server/keep_alive_spec.rb +67 -0
- data/spec/unit/server_spec.rb +13 -9
- data/spec/unit/support/message_spec.rb +5 -2
- metadata +5 -5
- data/lib/hatetepe/support/keep_alive.rb +0 -14
- data/spec/unit/support/keep_alive_spec.rb +0 -52
data/spec/unit/server_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe Hatetepe::Server do
|
|
15
15
|
close: nil)
|
16
16
|
end
|
17
17
|
let(:handler_class) { double('handler_class', new: handler) }
|
18
|
-
let(:handler) { double('handler',
|
18
|
+
let(:handler) { double('handler', setup: nil, respond: nil) }
|
19
19
|
|
20
20
|
describe '.start' do
|
21
21
|
specify { pending }
|
@@ -36,36 +36,40 @@ describe Hatetepe::Server do
|
|
36
36
|
it 'sets up handlers' do
|
37
37
|
expect(handler_class).to have_received(:new)
|
38
38
|
.with(config, server, connection)
|
39
|
-
expect(handler).to have_received(:
|
39
|
+
expect(handler).to have_received(:setup)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#serve' do
|
44
|
-
let(:request) {
|
45
|
-
let(:response) {
|
44
|
+
let(:request) { open_request }
|
45
|
+
let(:response) { open_response }
|
46
46
|
|
47
47
|
before do
|
48
48
|
allow(server).to receive(:respond)
|
49
|
-
allow(handler).to receive(:serve) {
|
49
|
+
allow(handler).to receive(:serve) { |_, served|
|
50
|
+
@served = served
|
51
|
+
@fiber = Fiber.current
|
52
|
+
}
|
50
53
|
end
|
51
54
|
|
52
55
|
subject! { server.serve(request) }
|
53
56
|
|
54
57
|
it 'sets up correlation' do
|
55
|
-
|
58
|
+
@served.fulfill(response)
|
56
59
|
tick
|
57
60
|
expect(server).to have_received(:respond).with(request, response)
|
58
61
|
end
|
59
62
|
|
60
63
|
it 'notifies the handlers' do
|
61
|
-
expect(handler).to have_received(:serve)
|
64
|
+
expect(handler).to have_received(:serve)
|
65
|
+
.with(request, kind_of(Hatetepe::Promise))
|
62
66
|
expect(@fiber).not_to be(Fiber.current)
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
70
|
describe '#respond' do
|
67
|
-
let(:request) {
|
68
|
-
let(:response) {
|
71
|
+
let(:request) { open_request }
|
72
|
+
let(:response) { open_response }
|
69
73
|
|
70
74
|
subject! { server.respond(request, response) }
|
71
75
|
|
@@ -3,12 +3,15 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Hatetepe::Support::Message do
|
6
|
+
let(:body) { double('body') }
|
7
|
+
before { allow(Hatetepe::Body).to receive(:new) { body } }
|
8
|
+
|
6
9
|
describe '.build', 'given a parser holding a request' do
|
7
10
|
let(:parser) do
|
8
11
|
Struct.new(:http_method, :request_url, :headers, :http_version)
|
9
12
|
.new('GET', '/', { 'Key' => 'value' }, [1, 1])
|
10
13
|
end
|
11
|
-
let(:args) { [:get, '/', { 'Key' => 'value' }] }
|
14
|
+
let(:args) { [:get, '/', { 'Key' => 'value' }, body] }
|
12
15
|
let(:request) { double }
|
13
16
|
|
14
17
|
subject { Hatetepe::Support::Message.build(parser) }
|
@@ -26,7 +29,7 @@ describe Hatetepe::Support::Message do
|
|
26
29
|
Struct.new(:http_method, :status_code, :headers, :http_version)
|
27
30
|
.new(nil, 200, { 'Key' => 'value' }, [1, 0])
|
28
31
|
end
|
29
|
-
let(:args) { [200, { 'Key' => 'value' }] }
|
32
|
+
let(:args) { [200, { 'Key' => 'value' }, body] }
|
30
33
|
let(:response) { double }
|
31
34
|
|
32
35
|
subject { Hatetepe::Support::Message.build(parser) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatetepe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.pre
|
4
|
+
version: 0.6.0.pre.1
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- config/yardstick.yml
|
103
103
|
- hatetepe.gemspec
|
104
104
|
- lib/hatetepe.rb
|
105
|
+
- lib/hatetepe/body.rb
|
105
106
|
- lib/hatetepe/client.rb
|
106
107
|
- lib/hatetepe/client/keep_alive.rb
|
107
108
|
- lib/hatetepe/client/timeouts.rb
|
@@ -117,7 +118,6 @@ files:
|
|
117
118
|
- lib/hatetepe/server/keep_alive.rb
|
118
119
|
- lib/hatetepe/server/timeouts.rb
|
119
120
|
- lib/hatetepe/support/handlers.rb
|
120
|
-
- lib/hatetepe/support/keep_alive.rb
|
121
121
|
- lib/hatetepe/support/message.rb
|
122
122
|
- lib/hatetepe/version.rb
|
123
123
|
- spec/integration/error_handling_spec.rb
|
@@ -133,8 +133,8 @@ files:
|
|
133
133
|
- spec/unit/connection/eventmachine_spec.rb
|
134
134
|
- spec/unit/request_spec.rb
|
135
135
|
- spec/unit/response_spec.rb
|
136
|
+
- spec/unit/server/keep_alive_spec.rb
|
136
137
|
- spec/unit/server_spec.rb
|
137
|
-
- spec/unit/support/keep_alive_spec.rb
|
138
138
|
- spec/unit/support/message_spec.rb
|
139
139
|
homepage: https://github.com/lgierth/hatetepe
|
140
140
|
licenses:
|
@@ -175,7 +175,7 @@ test_files:
|
|
175
175
|
- spec/unit/connection/eventmachine_spec.rb
|
176
176
|
- spec/unit/request_spec.rb
|
177
177
|
- spec/unit/response_spec.rb
|
178
|
+
- spec/unit/server/keep_alive_spec.rb
|
178
179
|
- spec/unit/server_spec.rb
|
179
|
-
- spec/unit/support/keep_alive_spec.rb
|
180
180
|
- spec/unit/support/message_spec.rb
|
181
181
|
has_rdoc:
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Hatetepe
|
4
|
-
module Support
|
5
|
-
module KeepAlive
|
6
|
-
CLOSE = 'close'.freeze
|
7
|
-
KEEP_ALIVE = 'keep-alive'.freeze
|
8
|
-
|
9
|
-
def close_connection?(version, header)
|
10
|
-
(version < 1.1 && header != KEEP_ALIVE) || header == CLOSE
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,52 +0,0 @@
|
|
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
|