From e0f9fb7cb8d8d47c68a9ebb0cb391d5880ca66d1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 2 Apr 2010 01:32:40 -0700 Subject: use duck typing for REMOTE_ADDR detection This gives us the option to use non-TCPSocket-derived IO-ish objects in the future, whatever that may be... --- lib/rainbows.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/rainbows.rb') diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 50db8a8..ccf211e 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -78,7 +78,8 @@ module Rainbows # For local UNIX domain sockets, this will return a string referred # to by the (non-frozen) Unicorn::HttpRequest::LOCALHOST constant. def addr(io) - TCPSocket == io ? io.peeraddr.last : Unicorn::HttpRequest::LOCALHOST + io.respond_to?(:peeraddr) ? + io.peeraddr.last : Unicorn::HttpRequest::LOCALHOST end end -- cgit v1.2.3-24-ge0c7