0
@@ -10,29 +10,29 @@ module Thin
0
CHUNKED_REGEXP = /\bchunked\b/i.freeze
0
# Rack application (adapter) served by this connection.
0
# Backend to the server
0
# Current request served by the connection
0
# Next response sent through the connection
0
attr_accessor :response
0
# Calling the application in a threaded allowing
0
# concurrent processing of requests.
0
# Get the connection ready to process a request.
0
@response = Response.new
0
# Called when data is received from the client.
0
@@ -42,7 +42,7 @@ module Thin
0
# Called when all data was received and the request
0
# is ready to be processed.
0
@@ -54,11 +54,11 @@ module Thin
0
post_process(pre_process)
0
# Add client info to the request env
0
@request.remote_address = remote_address
0
# Process the request calling the Rack adapter
0
@app.call(@request.env)
0
@@ -66,28 +66,28 @@ module Thin
0
nil # Signal to post_process that the request could not be processed
0
def post_process(result)
0
# Set the Content-Length header if possible
0
set_content_length(result) if need_content_length?(result)
0
@response.status, @response.headers, @response.body = result
0
log "!! Rack application returned nil body. Probably you wanted it to be an empty string?" if @response.body.nil?
0
# Make the response persistent if requested by the client
0
@response.persistent! if @request.persistent?
0
@response.each do |chunk|
0
# If no more request on that same connection, we close it.
0
close_connection_after_writing unless persistent?
0
@@ -108,18 +108,18 @@ module Thin
0
@request.close rescue nil
0
@response.close rescue nil
0
# Prepare the connection for another request if the client
0
# supports HTTP pipelining (persistent connection).
0
post_init if persistent?
0
# Called when the connection is unbinded from the socket
0
# and can no longer be used to process requests.
0
@backend.connection_finished(self)
0
# Allows this connection to be persistent.
0
@@ -135,14 +135,14 @@ module Thin
0
@can_persist && @response.persistent?
0
# +true+ if <tt>app.call</tt> will be called inside a thread.
0
# You can set all requests as threaded setting <tt>Connection#threaded=true</tt>
0
# or on a per-request case returning +true+ in <tt>app.deferred?</tt>.
0
@threaded || (@app.respond_to?(:deferred?) && @app.deferred?(@request.env))
0
# IP Address of the remote client.
0
@request.forwarded_for || socket_address
0
@@ -150,14 +150,14 @@ module Thin
0
# Returns IP address of peer as a string.
0
Socket.unpack_sockaddr_in(get_peername)[1]
0
def need_content_length?(result)
0
status, headers, body = result
0
@@ -167,7 +167,7 @@ module Thin
0
return false unless body.kind_of?(String) || body.kind_of?(Array)
0
def set_content_length(result)
0
headers, body = result[1..2]