From 20bf660a3efff9229c81b3b3a0feb6844bc27a7c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 30 Jun 2009 17:15:56 -0700 Subject: TrailerParser integration into ChunkedReader Support for the "Trailer:" header and associated Trailer lines should be reasonably well supported now --- lib/unicorn/chunked_reader.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/unicorn/chunked_reader.rb') diff --git a/lib/unicorn/chunked_reader.rb b/lib/unicorn/chunked_reader.rb index f9bd4ec..606e4a6 100644 --- a/lib/unicorn/chunked_reader.rb +++ b/lib/unicorn/chunked_reader.rb @@ -7,8 +7,8 @@ require 'unicorn/http11' module Unicorn class ChunkedReader - def initialize(input, buf) - @input, @buf = input, buf + def initialize(env, input, buf) + @env, @input, @buf = env, input, buf @chunk_left = 0 parse_chunk_header end @@ -71,6 +71,12 @@ module Unicorn @chunk_left = $1.to_i(16) if 0 == @chunk_left # EOF buf.sub!(/\A\r\n(?:\r\n)?/, Z) # cleanup for future requests + if trailer = @env[Const::HTTP_TRAILER] + tp = TrailerParser.new(trailer) + while ! tp.execute!(@env, buf) + buf << @input.readpartial(Const::CHUNK_SIZE) + end + end @input = nil end return @chunk_left -- cgit v1.2.3-24-ge0c7