From: Tom Hughes Date: Fri, 11 Apr 2025 23:06:30 +0000 (+0100) Subject: Avoid trying to rewind the request body X-Git-Tag: live~29^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/35022c47f97be69fd2dab75f7c3dfe1c8bd8af30 Avoid trying to rewind the request body Rack 3 no longer guarantees that the body is rewindable and in any case according the Apache bug just closing the stream is enough and avoid wasting time reading the body. --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 25de71f20..b10eec7d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base rescue_from RailsParam::InvalidParameterError, :with => :invalid_parameter - before_action :fetch_body + after_action :close_body attr_accessor :current_user, :oauth_token @@ -244,10 +244,10 @@ class ApplicationController < ActionController::Base # # https://issues.apache.org/bugzilla/show_bug.cgi?id=44782 # - # To work round this we call rewind on the body here, which is added - # as a filter, to force it to be fetched from Apache into a file. - def fetch_body - request.body.rewind + # To work round this we call close on the body here, which is added + # as a filter, to let Apache know we are done with it. + def close_body + request.body&.close end def map_layout