rack-parser 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/rack/parser.rb +1 -0
- data/rack-parser.gemspec +1 -1
- data/test/parser_test.rb +10 -1
- metadata +15 -15
data/README.md
CHANGED
@@ -98,13 +98,14 @@ This project came to being because of:
|
|
98
98
|
|
99
99
|
## External Sources/Documentations
|
100
100
|
|
101
|
-
* [Sinatra
|
101
|
+
* [Sinatra recipes](https://github.com/sinatra/sinatra-recipes/blob/master/middleware/rack_parser.md) - mini tutorial on using rack-parser (thanks to [Eric Gjertsen](https://github.com/ericgj))
|
102
102
|
|
103
103
|
|
104
104
|
## Contributors ##
|
105
105
|
|
106
106
|
* [Stephen Becker IV](https://github.com/sbeckeriv) - For initial custom error response handling work.
|
107
107
|
* [Tom May](https://github.com/tommay) - skip loading post body unless content type is set.
|
108
|
+
* [Moonsik Kang](https://github.com/deepblue) - skip rack parser for content types that are not explicitly set.
|
108
109
|
|
109
110
|
## Copyright
|
110
111
|
|
data/lib/rack/parser.rb
CHANGED
@@ -63,6 +63,7 @@ module Rack
|
|
63
63
|
|
64
64
|
def _call(env)
|
65
65
|
content_type = Rack::Request.new(env).media_type
|
66
|
+
return @app.call(env) if !@content_types[content_type] && !@error_responses[content_type]
|
66
67
|
body = env[POST_BODY].read if content_type
|
67
68
|
return @app.call(env) if (body.respond_to?(:empty?) ? body.empty? : !body) # Send it down the stack immediately
|
68
69
|
begin
|
data/rack-parser.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rack-parser"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.2"
|
7
7
|
s.authors = ["Arthur Chiu"]
|
8
8
|
s.email = ["mr.arthur.chiu@gmail.com"]
|
9
9
|
s.homepage = "https://www.github.com/achiu/rack-parser"
|
data/test/parser_test.rb
CHANGED
@@ -62,7 +62,7 @@ context "Rack::Parser" do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
asserts(:status).equals 400
|
65
|
-
asserts(:body).
|
65
|
+
asserts(:body).matches %r!{"errors":"\d+: unexpected token at 'fuuuuuuuuuu'"}!
|
66
66
|
end
|
67
67
|
|
68
68
|
context "with custom default error message" do
|
@@ -82,4 +82,13 @@ context "Rack::Parser" do
|
|
82
82
|
asserts(:body).matches %r{Hello world}
|
83
83
|
end
|
84
84
|
|
85
|
+
context "for get with unconcerned content_type" do
|
86
|
+
setup do
|
87
|
+
post '/post', 'foo=bar', { 'CONTENT_TYPE' => 'application/x-www-form-urlencoded' }
|
88
|
+
end
|
89
|
+
|
90
|
+
asserts(:status).equals 200
|
91
|
+
asserts(:body).equals({'foo' => 'bar'}.inspect)
|
92
|
+
end
|
93
|
+
|
85
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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: 2011-
|
12
|
+
date: 2011-10-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152479300 !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: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152479300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152478860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152478860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_xml
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152478400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152478400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: riot
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152477960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152477960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rack-test
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152477540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152477540
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
|
-
requirement: &
|
71
|
+
requirement: &2152477120 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2152477120
|
80
80
|
description: Rack Middleware for parsing post body data for json, xml and various
|
81
81
|
content types
|
82
82
|
email:
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project: rack-parser
|
117
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.10
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
120
|
summary: Rack Middleware for parsing post body data
|