reel-rack 0.2.1 → 0.2.2
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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/reel/rack/server.rb +23 -1
- data/lib/reel/rack/version.rb +1 -1
- data/spec/reel/rack/server_spec.rb +18 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc523b3bd8451f12b547c078df59cafa431f9fa2
|
|
4
|
+
data.tar.gz: 2cc6c4f427f567c7b0c3c1c55e1eabfc71487d35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c646547d89ee18f33fa25e53eacde194173aeefc6299b0cb74530f1dba89d92de3d852f83cbe199f40dc977d04ab8e9b0cff265a4de82de577a258f6755911b5
|
|
7
|
+
data.tar.gz: f044747dd5ec6c251d8290750cecc144af666ac0ff2a8000cbbeab714e31c947b0d69176a004f60ea704ee0b429ea2153ff0f83c2282f28f97027ff0e6a156b8
|
data/CHANGES.md
CHANGED
data/lib/reel/rack/server.rb
CHANGED
|
@@ -40,7 +40,9 @@ module Reel
|
|
|
40
40
|
:input => request.body.to_s,
|
|
41
41
|
"REMOTE_ADDR" => request.remote_addr
|
|
42
42
|
}.merge(convert_headers(request.headers))
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
normalize_env(options)
|
|
45
|
+
|
|
44
46
|
status, headers, body = app.call ::Rack::MockRequest.env_for(request.url, options)
|
|
45
47
|
|
|
46
48
|
if body.respond_to? :each
|
|
@@ -78,6 +80,26 @@ module Reel
|
|
|
78
80
|
}]
|
|
79
81
|
end
|
|
80
82
|
|
|
83
|
+
# Copied from lib/puma/server.rb
|
|
84
|
+
def normalize_env(env)
|
|
85
|
+
if host = env["HTTP_HOST"]
|
|
86
|
+
if colon = host.index(":")
|
|
87
|
+
env["SERVER_NAME"] = host[0, colon]
|
|
88
|
+
env["SERVER_PORT"] = host[colon+1, host.bytesize]
|
|
89
|
+
else
|
|
90
|
+
env["SERVER_NAME"] = host
|
|
91
|
+
env["SERVER_PORT"] = default_server_port(env)
|
|
92
|
+
end
|
|
93
|
+
else
|
|
94
|
+
env["SERVER_NAME"] = "localhost"
|
|
95
|
+
env["SERVER_PORT"] = default_server_port(env)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def default_server_port(env)
|
|
100
|
+
env['HTTP_X_FORWARDED_PROTO'] == 'https' ? 443 : 80
|
|
101
|
+
end
|
|
102
|
+
|
|
81
103
|
def status_symbol(status)
|
|
82
104
|
if status.is_a?(Fixnum)
|
|
83
105
|
Http::Response::STATUS_CODES[status].downcase.gsub(/\s|-/, '_').to_sym
|
data/lib/reel/rack/version.rb
CHANGED
|
@@ -10,10 +10,10 @@ describe Reel::Rack::Server do
|
|
|
10
10
|
let(:body) { "hello world" }
|
|
11
11
|
let(:uri) { URI("http://#{host}:#{port}/") }
|
|
12
12
|
let(:http) { Net::HTTP.new(uri.host, uri.port) }
|
|
13
|
+
let(:rack_app) { proc { [200, headers, [body]] } }
|
|
13
14
|
|
|
14
15
|
subject do
|
|
15
|
-
|
|
16
|
-
described_class.new(Rack::Lint.new(Rack::Head.new(app)), :Host => host, :Port => port)
|
|
16
|
+
described_class.new(Rack::Lint.new(Rack::Head.new(rack_app)), :Host => host, :Port => port)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
before do
|
|
@@ -53,4 +53,20 @@ describe Reel::Rack::Server do
|
|
|
53
53
|
expect(http.send_request('GET', uri.path, 'test')['transfer-encoding']).to eq 'chunked'
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
context "works with Rack::Builder" do
|
|
58
|
+
let(:rack_app) {
|
|
59
|
+
headers = {"Content-Type" => "text/plain"}
|
|
60
|
+
Rack::Builder.app {
|
|
61
|
+
map("/path1") { run proc { [200, headers.merge("Content-Length"=>"5"), ["path1"]] } }
|
|
62
|
+
run proc { [200, headers.merge("Content-Length"=>"3"), ["any"]] }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
it "routes the requests both exact path and any path" do
|
|
67
|
+
expect(http.send_request('GET', "/path1", 'test').body).to eq "path1"
|
|
68
|
+
expect(http.send_request('GET', "/", 'test').body).to eq "any"
|
|
69
|
+
expect(http.send_request('GET', "/path2", 'test').body).to eq "any"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
56
72
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reel-rack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony Arcieri
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: reel
|
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
129
|
version: '0'
|
|
130
130
|
requirements: []
|
|
131
131
|
rubyforge_project:
|
|
132
|
-
rubygems_version: 2.
|
|
132
|
+
rubygems_version: 2.4.5
|
|
133
133
|
signing_key:
|
|
134
134
|
specification_version: 4
|
|
135
135
|
summary: Rack adapter for Reel, a Celluloid::IO web server
|