]> git.openstreetmap.org Git - rails.git/commitdiff
Avoid trying to rewind the request body
authorTom Hughes <tom@compton.nu>
Fri, 11 Apr 2025 23:06:30 +0000 (00:06 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 15 Apr 2025 17:15:22 +0000 (18:15 +0100)
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.

app/controllers/application_controller.rb

index 25de71f20a1cdba2cc8b211ce316ad321f1604d7..b10eec7d3f4bdc2888fb85056e5f39e6efc73f1e 100644 (file)
@@ -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