magellan-rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/magellan/rails/request.rb +7 -7
- data/lib/magellan/rails/version.rb +1 -1
- data/spec/magellan/rails/request_spec.rb +20 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332b7e16cca102a6a4147f905d19e3e4a3e5e664
|
4
|
+
data.tar.gz: ec9343f83483a86de1766b7548990bd5af5b8e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df36c50d2f67c599e64f36186d1db49be0d4e7480a160b8cdef4fa059362c0fdc2d5560aabb0d50a2cc2f722a0281248ec91895854df1443e5a7144cd32fb50
|
7
|
+
data.tar.gz: f9c486e2431466fae90720cfcdae438d1f5ff222e02d5012077d427e5cdc00cd3d14f098911d50639a695fbfd8760df9f836a7d2a7afe46db98636bcc4d64694
|
@@ -31,7 +31,7 @@ class Magellan::Rails::Request
|
|
31
31
|
@options = {}
|
32
32
|
end
|
33
33
|
@env = request_message["env"] || {}
|
34
|
-
@headers = request_message['headers']
|
34
|
+
@headers = request_message['headers'].each_with_object({}){|(k, v), tbl| tbl[k.downcase] = v }
|
35
35
|
@body_encoding = request_message['body_encoding']
|
36
36
|
@body_encoding = (@body_encoding.present? and VALID_ENCODING.include?(@body_encoding)) ? @body_encoding.to_sym : :plain
|
37
37
|
@body = decode_body(request_message['body'], @body_encoding)
|
@@ -42,11 +42,11 @@ class Magellan::Rails::Request
|
|
42
42
|
|
43
43
|
case @version
|
44
44
|
when 1
|
45
|
-
http_method = @headers["
|
46
|
-
path_info = @headers["
|
47
|
-
query_string = @headers["
|
48
|
-
server_name = @headers["
|
49
|
-
server_port = @headers['
|
45
|
+
http_method = @headers["method"]
|
46
|
+
path_info = @headers["path-info"]
|
47
|
+
query_string = @headers["query-string"]
|
48
|
+
server_name = @headers["server-name"]
|
49
|
+
server_port = @headers['server-port'].to_s
|
50
50
|
when 2
|
51
51
|
http_method = @env["METHOD"]
|
52
52
|
path_info = @env["PATH_INFO"]
|
@@ -62,7 +62,7 @@ class Magellan::Rails::Request
|
|
62
62
|
# Rackにクエリーストリングを渡す時は
|
63
63
|
query_string.slice!(0) if (query_string[0] == '?')
|
64
64
|
|
65
|
-
ct = @headers["
|
65
|
+
ct = @headers["content-type"]
|
66
66
|
|
67
67
|
env["CONTENT_LENGTH"] = @body.bytesize
|
68
68
|
env["CONTENT_TYPE"] = ct.dup if ct
|
@@ -29,6 +29,20 @@ describe Magellan::Rails::Request do
|
|
29
29
|
# 'reply_ttl' => 1000
|
30
30
|
}
|
31
31
|
}
|
32
|
+
@downcased_headers = {
|
33
|
+
'title' => 'groovenauts-app',
|
34
|
+
'interface-version' => '1.0.0',
|
35
|
+
'title-runtime-version'=> '1.0.0',
|
36
|
+
'reference-id' => '192.168.1.110',
|
37
|
+
'url' => 'http://magellan-clouds.com/worker/test',
|
38
|
+
'oauth-requester-id' => 'tarou',
|
39
|
+
'content-type' => 'application/json',
|
40
|
+
'method' => 'GET',
|
41
|
+
"server-name" => "localhost",
|
42
|
+
"server-port" => 3000,
|
43
|
+
"path-info" => "/hello/index",
|
44
|
+
"query-string" => "qs1=abc&qs2=def"
|
45
|
+
}
|
32
46
|
end
|
33
47
|
|
34
48
|
context "valid format" do
|
@@ -44,7 +58,7 @@ describe Magellan::Rails::Request do
|
|
44
58
|
|
45
59
|
it do
|
46
60
|
request.parse_message(@request_message)
|
47
|
-
expect(request.headers).to eq(@
|
61
|
+
expect(request.headers).to eq(@downcased_headers)
|
48
62
|
expect(request.body ).to eq(@request_message['body'])
|
49
63
|
expect(request.options).to eq(@request_message['options'])
|
50
64
|
|
@@ -90,7 +104,7 @@ describe Magellan::Rails::Request do
|
|
90
104
|
|
91
105
|
it do
|
92
106
|
request.parse_message(@request_message)
|
93
|
-
expect(request.headers).to eq(@
|
107
|
+
expect(request.headers).to eq(@downcased_headers)
|
94
108
|
expect(request.body ).to eq(@request_message['body'])
|
95
109
|
expect(request.options).to eq(@request_message['options'])
|
96
110
|
end
|
@@ -110,7 +124,7 @@ describe Magellan::Rails::Request do
|
|
110
124
|
|
111
125
|
it do
|
112
126
|
request.parse_message(@request_message)
|
113
|
-
expect(request.headers).to eq(@
|
127
|
+
expect(request.headers).to eq(@downcased_headers)
|
114
128
|
expect(request.body.inspect).to eq(@request_body.inspect)
|
115
129
|
expect(request.options).to eq(@request_message['options'])
|
116
130
|
end
|
@@ -161,7 +175,7 @@ describe Magellan::Rails::Request do
|
|
161
175
|
|
162
176
|
it do
|
163
177
|
request.parse_message(@request_message)
|
164
|
-
expect(request.headers).to eq(
|
178
|
+
expect(request.headers).to eq({"content-type" => "application/json"})
|
165
179
|
expect(request.body ).to eq(@request_message['body'])
|
166
180
|
expect(request.options).to eq(@request_message['options'])
|
167
181
|
expected_env = {
|
@@ -200,7 +214,7 @@ describe Magellan::Rails::Request do
|
|
200
214
|
|
201
215
|
it do
|
202
216
|
request.parse_message(@request_message)
|
203
|
-
expect(request.headers).to eq(
|
217
|
+
expect(request.headers).to eq({"content-type" => "application/json"})
|
204
218
|
expect(request.body ).to eq(@request_message['body'])
|
205
219
|
expect(request.options).to eq(@request_message['options'])
|
206
220
|
end
|
@@ -220,7 +234,7 @@ describe Magellan::Rails::Request do
|
|
220
234
|
|
221
235
|
it do
|
222
236
|
request.parse_message(@request_message)
|
223
|
-
expect(request.headers).to eq(
|
237
|
+
expect(request.headers).to eq({"content-type" => "application/json"})
|
224
238
|
expect(request.body.inspect).to eq(@request_body.inspect)
|
225
239
|
expect(request.options).to eq(@request_message['options'])
|
226
240
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magellan-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuuki Noguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|