about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-08 15:44:57 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-08 15:44:57 +0100
commita8c854b3ea80724797dd18cfe047cdbf7075bda2 (patch)
tree480d2cf843d2034a84daa12ea84b29683997b46a /app/lib
parentac219dd1f6d660d3728c5881c4eb3b672fea432e (diff)
parent782b6835f786385c41c6455f2a251d1925b19eb5 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/request.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/lib/request.rb b/app/lib/request.rb
index 648aa3085..1ea86862d 100644
--- a/app/lib/request.rb
+++ b/app/lib/request.rb
@@ -62,8 +62,6 @@ class Request
     end
 
     begin
-      response = response.extend(ClientLimit)
-
       # If we are using a persistent connection, we have to
       # read every response to be able to move forward at all.
       # However, simply calling #to_s or #flush may not be safe,
@@ -181,6 +179,14 @@ class Request
     end
   end
 
+  if ::HTTP::Response.methods.include?(:body_with_limit) && !Rails.env.production?
+    abort 'HTTP::Response#body_with_limit is already defined, the monkey patch will not be applied'
+  else
+    class ::HTTP::Response
+      include Request::ClientLimit
+    end
+  end
+
   class Socket < TCPSocket
     class << self
       def open(host, *args)