diff options
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/chunked_reader.rb | 10 | ||||
-rw-r--r-- | lib/unicorn/const.rb | 1 | ||||
-rw-r--r-- | lib/unicorn/http_request.rb | 2 |
3 files changed, 10 insertions, 3 deletions
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 diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb index 9dcf031..be69753 100644 --- a/lib/unicorn/const.rb +++ b/lib/unicorn/const.rb @@ -32,6 +32,7 @@ module Unicorn REMOTE_ADDR="REMOTE_ADDR".freeze HTTP_X_FORWARDED_FOR="HTTP_X_FORWARDED_FOR".freeze HTTP_EXPECT="HTTP_EXPECT".freeze + HTTP_TRAILER="HTTP_TRAILER".freeze RACK_INPUT="rack.input".freeze STREAM_INPUT="unicorn.stream_input".freeze end diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index a6ed7c9..3df9120 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -96,7 +96,7 @@ module Unicorn if te = PARAMS[Const::HTTP_TRANSFER_ENCODING] if /\Achunked\z/i =~ te - socket = ChunkedReader.new(socket, body) + socket = ChunkedReader.new(PARAMS, socket, body) length = body = nil end end |