Skip to content

Commit

Permalink
Merge pull request #54 from costi/master
Browse files Browse the repository at this point in the history
Rewind the stream that holds the post body after reading from it
  • Loading branch information
rkh committed Dec 10, 2012
2 parents 7b0b109 + 281be28 commit 73975aa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/rack/contrib/post_body_content_type_parser.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 73975aa

Please sign in to comment.