From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Ben Somers Newsgroups: gmane.comp.lang.ruby.raindrops.general Subject: Raindrops::Middleware::Proxy claims to respond to #body when it does not? Date: Thu, 17 May 2012 12:07:42 -0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1337281728 10973 80.91.229.3 (17 May 2012 19:08:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 17 May 2012 19:08:48 +0000 (UTC) To: raindrops@librelist.org Original-X-From: raindrops@librelist.org Thu May 17 21:08:47 2012 Return-path: Envelope-to: gclrrg-raindrops@m.gmane.org In-Reply-To: List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: raindrops@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.raindrops.general:64 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SV643-0006WA-0q for gclrrg-raindrops@m.gmane.org; Thu, 17 May 2012 21:08:43 +0200 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id 4F3B721DB97 for ; Thu, 17 May 2012 19:16:16 +0000 (UTC) Hi, Currently working on the auto-scaler for unicorn that I mentioned on that mailing list back in January; I'm writing it as an external tool that polls against the raindrops middleware to get a crude metric of load. (Independently, I'd love your thoughts on whether that's a viable/problematic approach; I think I can safely use the active count, but details on exactly what those numbers mean would be cool). In the process, though, I enabled Raindrops::Middleware on a whole bunch of servers that weren't running it before, and started getting some pretty weird errors on a few of them. Those boxes run a separate middleware that writes xml requests to a log file; in the process, they call #body on the response object. This works great when they're receiving ActionController::Response objects from Rails, but blows up on Raindrops::Middleware::Proxy objects. What I'm seeing is that the response passed to my logger middleware is a Raindrops::Middleware::Proxy, with an ActionDispatch::Response set as its @body. The ActionDispatch::Response responds to #body; the Raindrops::Middleware::Proxy does not, since it has its body in a plain instance variable without an accessor. This tricked my initial workaround, which was to only log the body if the response responded to #body, because the Middleware::Proxy winds up claiming that it can respond when in fact it cannot. It does so because it delegates :respond_to? to its body in almost all cases. Clearly the Raindrops::Middleware::Proxy has #respond_to? implemented the way it is for a reason, but it seems awfully counterintuitive. Thoughts/answers? Not necessarily looking for any action here, just trying to understand what's going on and why. -ben PS And yes, I'm totally aware that this logger middleware is dependent on an interface not provided for in the Rack specification. I've already complained to its author about this, though it probably falls on me to correct that. PPS Running on unicorn 4.3.1, raindrops 0.8.1, and rails 3.0.10, if that's of any concern.