rack-parser 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,6 @@ module Rack
12
12
  class Parser
13
13
 
14
14
  # Rack Constants
15
- HEADER_CONTENT_TYPE = 'Content-Type'.freeze
16
15
  POST_BODY = 'rack.input'.freeze
17
16
  FORM_INPUT = 'rack.request.form_input'.freeze
18
17
  FORM_HASH = 'rack.request.form_hash'.freeze
@@ -43,7 +42,7 @@ module Rack
43
42
  def _call(env)
44
43
  body = env[POST_BODY].read
45
44
  return @app.call(env) if (body.respond_to?(:empty?) ? body.empty? : !body) # Send it down the stack immediately
46
- content_type = env[HEADER_CONTENT_TYPE]
45
+ content_type = Rack::Request.new(env).media_type
47
46
  format = content_type.split('/').last
48
47
  begin
49
48
  result = @content_types[content_type].call(body)
@@ -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.0.3"
6
+ s.version = "0.0.4"
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"
@@ -29,7 +29,7 @@ context "Rack::Parser" do
29
29
 
30
30
  context "with json" do
31
31
  setup do
32
- post '/post', "{\"test\":1,\"foo\":2,\"bar\":\"3\"}", { 'Content-Type' => 'application/json' }
32
+ post '/post', "{\"test\":1,\"foo\":2,\"bar\":\"3\"}", { 'CONTENT_TYPE' => 'application/json' }
33
33
  end
34
34
 
35
35
  asserts(:status).equals 200
@@ -38,7 +38,7 @@ context "Rack::Parser" do
38
38
 
39
39
  context "with xml" do
40
40
  setup do
41
- put '/post', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <a type=\"integer\">1</a>\n</hash>\n", { 'Content-Type' => 'application/xml'}
41
+ put '/post', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <a type=\"integer\">1</a>\n</hash>\n", { 'CONTENT_TYPE' => 'application/xml'}
42
42
  end
43
43
 
44
44
  asserts(:status).equals 200
@@ -47,7 +47,7 @@ context "Rack::Parser" do
47
47
 
48
48
  context "with custom 'foo'" do
49
49
  setup do
50
- post '/post', 'something that does not matter', { 'Content-Type' => 'application/foo' }
50
+ post '/post', 'something that does not matter', { 'CONTENT_TYPE' => 'application/foo' }
51
51
  end
52
52
 
53
53
  asserts(:status).equals 200
@@ -56,7 +56,7 @@ context "Rack::Parser" do
56
56
 
57
57
  context "with bad data" do
58
58
  setup do
59
- post '/post', "fuuuuuuuuuu", { 'Content-Type' => 'application/json' }
59
+ post '/post', "fuuuuuuuuuu", { 'CONTENT_TYPE' => 'application/json' }
60
60
  end
61
61
 
62
62
  asserts(:status).equals 400
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rack-parser
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Arthur Chiu
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-13 00:00:00 Z
13
+ date: 2011-07-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack