rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / code / Atom feed
* Why Thin handler uses "Chunked" Trasfer-Encoding?
@ 2009-12-06  0:40 Iñaki Baz Castillo
  2009-12-06  0:50 ` Ryan Tomayko
  0 siblings, 1 reply; 3+ messages in thread
From: Iñaki Baz Castillo @ 2009-12-06  0:40 UTC (permalink / raw)
  To: rack-devel

Hi, Thin adapter looks like:

-------------------------------------
require "thin"
require "rack/content_length"
require "rack/chunked"

module Rack
  module Handler
    class Thin
      def self.run(app, options={})
        app = Rack::Chunked.new(Rack::ContentLength.new(app))
        server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
                                    options[:Port] || 8080,
                                    app)
        yield server if block_given?
        server.start
      end
    end
  end
end
-----------------------------

Why to force "Chunked"?



-- 
Iñaki Baz Castillo <ibc@aliax.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why Thin handler uses "Chunked" Trasfer-Encoding?
  2009-12-06  0:40 Why Thin handler uses "Chunked" Trasfer-Encoding? Iñaki Baz Castillo
@ 2009-12-06  0:50 ` Ryan Tomayko
  2009-12-06  0:55   ` Iñaki Baz Castillo
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Tomayko @ 2009-12-06  0:50 UTC (permalink / raw)
  To: rack-devel

On Sat, Dec 5, 2009 at 4:40 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
> Hi, Thin adapter looks like:
>
> -------------------------------------
> require "thin"
> require "rack/content_length"
> require "rack/chunked"
>
> module Rack
>  module Handler
>    class Thin
>      def self.run(app, options={})
>        app = Rack::Chunked.new(Rack::ContentLength.new(app))
>        server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
>                                    options[:Port] || 8080,
>                                    app)
>        yield server if block_given?
>        server.start
>      end
>    end
>  end
> end
> -----------------------------
>
> Why to force "Chunked"?

That only applies chunked encoding if no Content-Length response
header exists at that point in the middleware chain. I believe all
Rack adapters that don't support chunked encoding internally follow
the same pattern.

More here:

http://github.com/rack/rack/blob/master/lib/rack/chunked.rb#L18-26

Thanks,
Ryan
-- 
# tomayko.com/about

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why Thin handler uses "Chunked" Trasfer-Encoding?
  2009-12-06  0:50 ` Ryan Tomayko
@ 2009-12-06  0:55   ` Iñaki Baz Castillo
  0 siblings, 0 replies; 3+ messages in thread
From: Iñaki Baz Castillo @ 2009-12-06  0:55 UTC (permalink / raw)
  To: rack-devel

El Domingo, 6 de Diciembre de 2009, Ryan Tomayko escribió:
> On Sat, Dec 5, 2009 at 4:40 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
> > Hi, Thin adapter looks like:
> >
> > -------------------------------------
> > require "thin"
> > require "rack/content_length"
> > require "rack/chunked"
> >
> > module Rack
> >  module Handler
> >    class Thin
> >      def self.run(app, options={})
> >        app = Rack::Chunked.new(Rack::ContentLength.new(app))
> >        server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
> >                                    options[:Port] || 8080,
> >                                    app)
> >        yield server if block_given?
> >        server.start
> >      end
> >    end
> >  end
> > end
> > -----------------------------
> >
> > Why to force "Chunked"?
> 
> That only applies chunked encoding if no Content-Length response
> header exists at that point in the middleware chain. I believe all
> Rack adapters that don't support chunked encoding internally follow
> the same pattern.

Thanks for the explanation.

-- 
Iñaki Baz Castillo <ibc@aliax.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-06  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-06  0:40 Why Thin handler uses "Chunked" Trasfer-Encoding? Iñaki Baz Castillo
2009-12-06  0:50 ` Ryan Tomayko
2009-12-06  0:55   ` Iñaki Baz Castillo

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/rack.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).