raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
From: Dmytro Shteflyuk <kpumuk@kpumuk.info>
To: raindrops-public@bogomips.org
Cc: Dmytro Shteflyuk <kpumuk@kpumuk.info>
Subject: [PATCH] Properly override respond_to? in Raindrops::Middleware::Proxy
Date: Tue, 25 Jul 2017 16:02:42 -0400
Message-ID: <20170725200242.54318-1-kpumuk@kpumuk.info> (raw)

Correct method definition according to Ruby documentation (https://ruby-doc.org/core-2.4.1/Object.html#method-i-respond_to-3F) is:

    respond_to?(string, include_all=false) → true or false

Rack started using second argument starting from version 2:

https://github.com/rack/rack/blob/master/lib/rack/body_proxy.rb#L14

If raindrops is used in Rack 2+ applications, an exception is raised:

    ArgumentError: wrong number of arguments (2 for 1)
        <ROOT>/gems/raindrops-0.18.0/lib/raindrops/middleware/proxy.rb:30:in `respond_to?'
        <ROOT>/gems/rack-2.0.3/lib/rack/body_proxy.rb:14:in `respond_to?'
---
 lib/raindrops/middleware/proxy.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/raindrops/middleware/proxy.rb b/lib/raindrops/middleware/proxy.rb
index 1cf437c..a7c8e66 100644
--- a/lib/raindrops/middleware/proxy.rb
+++ b/lib/raindrops/middleware/proxy.rb
@@ -27,9 +27,9 @@ def to_path
 
   # Rack servers use +respond_to?+ to check for the presence of +close+
   # and +to_path+ methods.
-  def respond_to?(m)
+  def respond_to?(m, include_all = false)
     m = m.to_sym
-    :close == m || @body.respond_to?(m)
+    :close == m || @body.respond_to?(m, include_all)
   end
 
   # Avoid breaking users of non-standard extensions (e.g. #body)
-- 
2.13.2


             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 20:02 Dmytro Shteflyuk [this message]
2017-07-25 21:38 ` Eric Wong

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://bogomips.org/raindrops/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170725200242.54318-1-kpumuk@kpumuk.info \
    --to=kpumuk@kpumuk.info \
    --cc=raindrops-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

raindrops RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/raindrops-public
	git clone --mirror http://ou63pmih66umazou.onion/raindrops-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.raindrops

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git