unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: mongrel-unicorn@rubyforge.org
Subject: [PATCH] Rack::Chunked and ContentLength middlewares by default
Date: Fri, 19 Aug 2011 21:07:49 +0000	[thread overview]
Message-ID: <20110819210749.GA6809@dcvr.yhbt.net> (raw)

This was prompted by the recent thread in
http://thread.gmane.org/gmane.comp.lang.ruby.unicorn.general/1106
starting with Message-ID:
  CAL3dLFrkDix=L-STUnrxy7Wuc4wDZOb05NLbG6HABvFJNGmnmQ@mail.gmail.com

Rainbows! users have also run into this problem a few times, too:
  AANLkTimSuK7-ihgCa00D-fot4U-FbZt2diQFndyN4uit@mail.gmail.com
  2B157204-E5C6-4F5D-98A9-E2A79F9F9765@christophsturm.com

>From 1077961a3f8933c65d39c7e6c9ed6ff3b6b53647 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Fri, 19 Aug 2011 20:47:29 +0000
Subject: [PATCH] Rack::Chunked and ContentLength middlewares by default

This is needed to match the behavior of Rack::Server for
RACK_ENV=(deployment|development), actually.  This won't
affect users of other RACK_ENV values.

This change has minor performance consequences, so users
negatively affected should set RACK_ENV to "none" instead for
full control of their middleware stack.

This mainly affects Rainbows!/Zbatery users since they have
persistent connections and /need/ Content-Length or
Transfer-Encoding:chunked headers.
---
 lib/unicorn.rb |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index bb5409b..b882ce3 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -50,9 +50,14 @@ module Unicorn
       pp({ :inner_app => inner_app }) if $DEBUG
 
       # return value, matches rackup defaults based on env
+      # Unicorn does not support persistent connections, but Rainbows!
+      # and Zbatery both do.  Users accustomed to the Rack::Server default
+      # middlewares will need ContentLength/Chunked middlewares.
       case ENV["RACK_ENV"]
       when "development"
         Rack::Builder.new do
+          use Rack::ContentLength
+          use Rack::Chunked
           use Rack::CommonLogger, $stderr
           use Rack::ShowExceptions
           use Rack::Lint
@@ -60,6 +65,8 @@ module Unicorn
         end.to_app
       when "deployment"
         Rack::Builder.new do
+          use Rack::ContentLength
+          use Rack::Chunked
           use Rack::CommonLogger, $stderr
           run inner_app
         end.to_app
-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


                 reply	other threads:[~2011-08-19 22:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly 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://yhbt.net/unicorn/

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

  git send-email \
    --in-reply-to=20110819210749.GA6809@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).