Class: ActionController::CgiResponse

Inherits:
AbstractResponse show all
Defined in:
lib/action_controller/cgi_process.rb

Overview

:nodoc:

Constant Summary

Constants inherited from AbstractResponse

AbstractResponse::DEFAULT_HEADERS

Instance Attribute Summary

Attributes inherited from AbstractResponse

#assigns, #body, #cookies, #headers, #layout, #redirected_to, #redirected_to_method_params, #session, #template

Instance Method Summary collapse

Methods inherited from AbstractResponse

#charset, #charset=, #content_type, #content_type=, #redirect

Constructor Details

#initialize(cgi) ⇒ CgiResponse

Returns a new instance of CgiResponse.



180
181
182
183
# File 'lib/action_controller/cgi_process.rb', line 180

def initialize(cgi)
  @cgi = cgi
  super()
end

Instance Method Details

#out(output = $stdout) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/action_controller/cgi_process.rb', line 185

def out(output = $stdout)
  convert_content_type!
  set_content_length!

  output.binmode      if output.respond_to?(:binmode)
  output.sync = false if output.respond_to?(:sync=)

  begin
    output.write(@cgi.header(@headers))

    if @cgi.send(:env_table)['REQUEST_METHOD'] == 'HEAD'
      return
    elsif @body.respond_to?(:call)
      # Flush the output now in case the @body Proc uses
      # #syswrite.
      output.flush if output.respond_to?(:flush)
      @body.call(self, output)
    else
      output.write(@body)
    end

    output.flush if output.respond_to?(:flush)
  rescue Errno::EPIPE, Errno::ECONNRESET
    # lost connection to parent process, ignore output
  end
end