committee 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/committee/request_unpacker.rb +2 -2
- data/lib/committee/response_validator.rb +5 -7
- data/test/response_validator_test.rb +10 -7
- 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: 5e19343ffb0ef2e64ac07c4cac4b0cfea513dfb1
|
4
|
+
data.tar.gz: db3766715d0b18b7ebfb4f36753f089c981a099e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28f2a33a2c378ec68b302c0391172cda7f2bc12e344abc250f7d42ec952833cdd8e0bf146d6019b965ca0f1ec577e66fcfbdec5d2d44497947a48f284ef4e05
|
7
|
+
data.tar.gz: 9f13aea9de25ad5b03968f249fb2052cb9b2eb0ba9eb4d2c43b82eaa21b3977dfa29e3112d82e211947b27a0afc15a4f8b3a52cfd678bf768a1424e52794b338
|
@@ -11,7 +11,7 @@ module Committee
|
|
11
11
|
def call
|
12
12
|
# if Content-Type is empty or JSON, and there was a request body, try to
|
13
13
|
# interpret it as JSON
|
14
|
-
params = if !@request.
|
14
|
+
params = if !@request.media_type || @request.media_type =~ %r{application/.*json}
|
15
15
|
parse_json
|
16
16
|
elsif @optimistic_json
|
17
17
|
parse_json rescue MultiJson::LoadError nil
|
@@ -19,7 +19,7 @@ module Committee
|
|
19
19
|
|
20
20
|
params = if params
|
21
21
|
params
|
22
|
-
elsif @allow_form_params && @request.
|
22
|
+
elsif @allow_form_params && @request.media_type == "application/x-www-form-urlencoded"
|
23
23
|
# Actually, POST means anything in the request body, could be from
|
24
24
|
# PUT or PATCH too. Silly Rack.
|
25
25
|
indifferent_params(@request.POST)
|
@@ -11,7 +11,8 @@ module Committee
|
|
11
11
|
|
12
12
|
def call(status, headers, data)
|
13
13
|
unless status == 204 # 204 No Content
|
14
|
-
|
14
|
+
response = Rack::Response.new(data, status, headers)
|
15
|
+
check_content_type!(response)
|
15
16
|
end
|
16
17
|
|
17
18
|
if @link.rel == "instances" && !@link.target_schema
|
@@ -35,13 +36,10 @@ module Committee
|
|
35
36
|
|
36
37
|
private
|
37
38
|
|
38
|
-
def check_content_type!(
|
39
|
-
match
|
40
|
-
headers["Content-Type"] =~ m
|
41
|
-
}
|
42
|
-
unless match
|
39
|
+
def check_content_type!(response)
|
40
|
+
unless Rack::Mime.match?(response.content_type.to_s, @link.enc_type)
|
43
41
|
raise Committee::InvalidResponse,
|
44
|
-
%{"Content-Type" response header must be set to "
|
42
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
@@ -35,21 +35,24 @@ describe Committee::ResponseValidator do
|
|
35
35
|
assert_equal message, e.message
|
36
36
|
end
|
37
37
|
|
38
|
-
it "detects
|
38
|
+
it "detects a blank response Content-Type" do
|
39
39
|
@headers = {}
|
40
40
|
e = assert_raises(Committee::InvalidResponse) { call }
|
41
41
|
message =
|
42
|
-
%{"Content-Type" response header must be set to "
|
42
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
43
43
|
assert_equal message, e.message
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
47
|
-
@
|
48
|
-
call
|
46
|
+
it "detects an invalid response Content-Type" do
|
47
|
+
@headers = { "Content-Type" => "text/html" }
|
48
|
+
e = assert_raises(Committee::InvalidResponse) { call }
|
49
|
+
message =
|
50
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
51
|
+
assert_equal message, e.message
|
49
52
|
end
|
50
53
|
|
51
|
-
it "allows
|
52
|
-
@headers = {
|
54
|
+
it "allows no Content-Type for 204 No Content" do
|
55
|
+
@status, @headers = 204, {}
|
53
56
|
call
|
54
57
|
end
|
55
58
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_schema
|