Skip to content
Browse files

Extract parse_query and parse_multipart in Request so subclasses

can change their behavior [#71 state:resolved]
  • Loading branch information...
1 parent fb32ff7 commit d8ccbf37576d53fe37489d818b63def524df1a44 @josh josh committed Dec 20, 2009
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/rack/request.rb
View
17 lib/rack/request.rb
@@ -124,8 +124,7 @@ def GET
@env["rack.request.query_hash"]
else
@env["rack.request.query_string"] = query_string
- @env["rack.request.query_hash"] =
- Utils.parse_nested_query(query_string)
+ @env["rack.request.query_hash"] = parse_query(query_string)
end
end
@@ -140,15 +139,14 @@ def POST
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
@env["rack.request.form_input"] = @env["rack.input"]
- unless @env["rack.request.form_hash"] =
- Utils::Multipart.parse_multipart(env)
+ unless @env["rack.request.form_hash"] = parse_multipart(env)
form_vars = @env["rack.input"].read
# Fix for Safari Ajax postings that always append \0
form_vars.sub!(/\0\z/, '')
@env["rack.request.form_vars"] = form_vars
- @env["rack.request.form_hash"] = Utils.parse_nested_query(form_vars)
+ @env["rack.request.form_hash"] = parse_query(form_vars)
@env["rack.input"].rewind
end
@@ -256,5 +254,14 @@ def ip
@env['REMOTE_ADDR']
end
end
+
+ protected
+ def parse_query(qs)
+ Utils.parse_nested_query(qs)
+ end
+
+ def parse_multipart(env)
+ Utils::Multipart.parse_multipart(env)
+ end
end
end

0 comments on commit d8ccbf3

Please sign in to comment.
Something went wrong with that request. Please try again.