Install workarounds for running with unreleased versions of unicorn
for now, as unicorn 5.x will be dropping many needless features.
---
 lib/yahns.rb             | 4 +++-
 lib/yahns/http_client.rb | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/yahns.rb b/lib/yahns.rb
index d48b34d..a55837f 100644
--- a/lib/yahns.rb
+++ b/lib/yahns.rb
@@ -10,7 +10,9 @@ require 'sleepy_penguin'
 # on unicorn at all
 [ :ClientShutdown, :Const, :SocketHelper, :StreamInput, :TeeInput,
   :SSLConfigurator, :Configurator, :TmpIO, :Util, :Worker, :SSLServer,
-  :HttpServer ].each { |sym| Unicorn.__send__(:remove_const, sym) }
+  :HttpServer ].each do |sym|
+    Unicorn.__send__(:remove_const, sym) if Unicorn.const_defined?(sym)
+end
 
 # yahns exposes no user-visible API outside of the config file
 # Internals are subject to change.
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index a294511..15ee9d4 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -4,8 +4,9 @@
 class Yahns::HttpClient < Kgio::Socket # :nodoc:
   NULL_IO = StringIO.new("")
 
-  # FIXME: we shouldn't have this at all
-  Unicorn::HttpParser.keepalive_requests = 0xffffffff
+  # FIXME: we shouldn't have this at all when we go Unicorn 5-only
+  Unicorn::HttpParser.respond_to?(:keepalive_requests=) and
+    Unicorn::HttpParser.keepalive_requests = 0xffffffff
 
   include Yahns::HttpResponse
   QEV_FLAGS = Yahns::Queue::QEV_RD # used by acceptor
-- 
EW


Reply via email to