Method: Thin::Connection#post_process

Defined in:
lib/thin/connection.rb

#post_process(result) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/thin/connection.rb', line 89

def post_process(result)
  return unless result
  result = result.to_a
  
  # Status code -1 indicates that we're going to respond later (async).
  return if result.first == AsyncResponse.first

  @response.status, @response.headers, @response.body = *result

  log "!! Rack application returned nil body. Probably you wanted it to be an empty string?" if @response.body.nil?

  # Make the response persistent if requested by the client
  @response.persistent! if @request.persistent?

  # Send the response
  @response.each do |chunk|
    trace { chunk }
    send_data chunk
  end

rescue Exception
  handle_error
ensure
  # If the body is being deferred, then terminate afterward.
  if @response.body.respond_to?(:callback) && @response.body.respond_to?(:errback)
    @response.body.callback { terminate_request }
    @response.body.errback  { terminate_request }
  else
    # Don't terminate the response if we're going async.
    terminate_request unless result && result.first == AsyncResponse.first
  end
end