rack-post-body-to-params 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rack/post-body-to-params.rb +2 -3
- data/rack-post-body-to-params.gemspec +2 -2
- data/test/test_post-body-to-params.rb +7 -1
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -80,10 +80,9 @@ module Rack
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def call(env)
|
83
|
-
content_type = env[CONTENT_TYPE]
|
84
|
-
content_type = content_type.split(';').first
|
83
|
+
content_type = env[CONTENT_TYPE] && env[CONTENT_TYPE].split(';').first
|
85
84
|
|
86
|
-
if @content_types.include?
|
85
|
+
if content_type && @content_types.include?(content_type)
|
87
86
|
post_body = env[POST_BODY].read
|
88
87
|
|
89
88
|
unless post_body.blank?
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rack-post-body-to-params"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Niko Dittmann"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-02"
|
13
13
|
s.email = "mail+git@niko-dittmann.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -98,7 +98,7 @@ class TestPostBodyToParams < Test::Unit::TestCase
|
|
98
98
|
assert_equal({"bla"=>"blub"}, new_env['rack.request.form_hash'])
|
99
99
|
assert_equal env['rack.input'], new_env['rack.request.form_input']
|
100
100
|
end
|
101
|
-
should "
|
101
|
+
should "work with charset specification, too" do
|
102
102
|
env = {
|
103
103
|
'CONTENT_TYPE' => 'application/json; charset=ISO-8859-1',
|
104
104
|
'rack.input' => StringIO.new('{"bla":"blub"}')
|
@@ -107,6 +107,12 @@ class TestPostBodyToParams < Test::Unit::TestCase
|
|
107
107
|
assert_equal({"bla"=>"blub"}, new_env['rack.request.form_hash'])
|
108
108
|
assert_equal env['rack.input'], new_env['rack.request.form_input']
|
109
109
|
end
|
110
|
+
should "work without any content type" do
|
111
|
+
env = {
|
112
|
+
'rack.input' => StringIO.new('{"bla":"blub"}')
|
113
|
+
}
|
114
|
+
new_env = @app.call(env) # doesnt raise
|
115
|
+
end
|
110
116
|
should "return 400 and the error message on faulty json" do
|
111
117
|
env = {
|
112
118
|
'CONTENT_TYPE' => 'application/json',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-post-body-to-params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &70202281553420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70202281553420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70202281552100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.3'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70202281552100
|
36
36
|
description:
|
37
37
|
email: mail+git@niko-dittmann.com
|
38
38
|
executables: []
|