mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
drop a conditional by always assigning
We will always make an assignment to the env hash and eliminate a conditional
This commit is contained in:
parent
fabcdc711b
commit
a1d7d65f0a
1 changed files with 5 additions and 6 deletions
|
@ -26,20 +26,19 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
if params = parse_formatted_parameters(env)
|
default = env["action_dispatch.request.request_parameters"]
|
||||||
env["action_dispatch.request.request_parameters"] = params
|
env["action_dispatch.request.request_parameters"] = parse_formatted_parameters(env, default)
|
||||||
end
|
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def parse_formatted_parameters(env)
|
def parse_formatted_parameters(env, default)
|
||||||
request = Request.new(env)
|
request = Request.new(env)
|
||||||
|
|
||||||
return false if request.content_length.zero?
|
return default if request.content_length.zero?
|
||||||
|
|
||||||
strategy = @parsers.fetch(request.content_mime_type) { return false }
|
strategy = @parsers.fetch(request.content_mime_type) { return default }
|
||||||
|
|
||||||
strategy.call(request.raw_post)
|
strategy.call(request.raw_post)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue