0
@@ -5,7 +5,7 @@ module Thin
0
# Raised when an incoming request is not valid
0
# and the server can not process it.
0
class InvalidRequest < IOError; end
0
# A request sent by the client to the server.
0
# Maximum request body size before it is moved out of memory
0
@@ -13,7 +13,7 @@ module Thin
0
MAX_BODY = 1024 * (80 + 32)
0
BODY_TMPFILE = 'thin-body'.freeze
0
MAX_HEADER = 1024 * (80 + 32)
0
# Freeze some HTTP header names & values
0
SERVER_SOFTWARE = 'SERVER_SOFTWARE'.freeze
0
HTTP_VERSION = 'HTTP_VERSION'.freeze
0
@@ -24,7 +24,7 @@ module Thin
0
CONNECTION = 'HTTP_CONNECTION'.freeze
0
KEEP_ALIVE_REGEXP = /\bkeep-alive\b/i.freeze
0
CLOSE_REGEXP = /\bclose\b/i.freeze
0
# Freeze some Rack header names
0
RACK_INPUT = 'rack.input'.freeze
0
RACK_VERSION = 'rack.version'.freeze
0
@@ -32,16 +32,16 @@ module Thin
0
RACK_MULTITHREAD = 'rack.multithread'.freeze
0
RACK_MULTIPROCESS = 'rack.multiprocess'.freeze
0
RACK_RUN_ONCE = 'rack.run_once'.freeze
0
# CGI-like request environment variables
0
# Unparsed data of the request
0
@parser = HttpParser.new
0
@@ -49,36 +49,36 @@ module Thin
0
SERVER_SOFTWARE => SERVER,
0
RACK_VERSION => VERSION::RACK,
0
RACK_MULTITHREAD => false,
0
RACK_MULTIPROCESS => false,
0
# Parse a chunk of data into the request environment
0
# Raises a +InvalidRequest+ if invalid.
0
# Returns +true+ if the parsing is complete.
0
if @parser.finished? # Header finished, can only be some more body
0
else # Parse more header using the super parser
0
- raise InvalidRequest, 'Header longer than allowed' if @data.size > MAX_HEADER
0
+ raise InvalidRequest, 'Header longer than allowed' if @data.size > MAX_HEADER
0
@nparsed = @parser.execute(@env, @data, @nparsed)
0
# Transfert to a tempfile if body is very big
0
move_body_to_tempfile if @parser.finished? && content_length > MAX_BODY
0
if finished? # Check if header and body are complete
0
@@ -87,17 +87,17 @@ module Thin
0
false # Not finished, need more data
0
# +true+ if headers and body are finished parsing
0
@parser.finished? && @body.size >= content_length
0
# Expected size of the body
0
@env[CONTENT_LENGTH].to_i
0
# Returns +true+ if the client expect the connection to be persistent.
0
# Clients and servers SHOULD NOT assume that a persistent connection
0
@@ -105,7 +105,7 @@ module Thin
0
# signaled. (http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html)
0
if @env[HTTP_VERSION] == HTTP_1_0
0
@env[CONNECTION] =~ KEEP_ALIVE_REGEXP
0
# HTTP/1.1 client intends to maintain a persistent connection unless
0
# a Connection header including the connection-token "close" was sent
0
@@ -113,24 +113,24 @@ module Thin
0
@env[CONNECTION].nil? || @env[CONNECTION] !~ CLOSE_REGEXP
0
def remote_address=(address)
0
@env[REMOTE_ADDR] = address
0
@env[RACK_MULTITHREAD] = value
0
# Close any resource used by the request
0
@body.delete if @body.class == Tempfile
0
def move_body_to_tempfile
0
@@ -138,7 +138,7 @@ module Thin
0
@body = Tempfile.new(BODY_TMPFILE)
0
@body << current_body.read
0
- @env[RACK_INPUT] = @body
0
+ @env[RACK_INPUT] = @body
0
\ No newline at end of file