Browse files

Merge pull request #54 from costi/master

Rewind the stream that holds the post body after reading from it
  • Loading branch information...
2 parents 7b0b109 + 281be28 commit 73975aad3983f587dda7d444600912a14646cceb @rkh rkh committed Dec 10, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/rack/contrib/post_body_content_type_parser.rb
View
1 lib/rack/contrib/post_body_content_type_parser.rb
@@ -30,6 +30,7 @@ def initialize(app)
def call(env)
if Rack::Request.new(env).media_type == APPLICATION_JSON && (body = env[POST_BODY].read).length != 0
+ env[POST_BODY].rewind # somebody might try to read this stream
env.update(FORM_HASH => JSON.parse(body), FORM_INPUT => env[POST_BODY])
end
@app.call(env)

0 comments on commit 73975aa

Please sign in to comment.