Permalink
Browse files

pay attention to rack.request.form_vars to handle cases where another…

… middleware already processed form input
  • Loading branch information...
1 parent e192c10 commit ba037b97c806539540435c587441581151654f6b @mislav committed Jan 14, 2009
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/rack/contrib/nested_params.rb
@@ -9,6 +9,7 @@ class NestedParams
POST_BODY = 'rack.input'.freeze
FORM_INPUT = 'rack.request.form_input'.freeze
FORM_HASH = 'rack.request.form_hash'.freeze
+ FORM_VARS = 'rack.request.form_vars'.freeze
# supported content type
URL_ENCODED = 'application/x-www-form-urlencoded'.freeze
@@ -18,7 +19,9 @@ def initialize(app)
end
def call(env)
- if env[CONTENT_TYPE] == URL_ENCODED
+ if form_vars = env[FORM_VARS]
+ env[FORM_HASH] = parse_query_parameters(form_vars)
+ elsif env[CONTENT_TYPE] == URL_ENCODED
post_body = env[POST_BODY]
env[FORM_INPUT] = post_body
env[FORM_HASH] = parse_query_parameters(post_body.read)

0 comments on commit ba037b9

Please sign in to comment.