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, #redirected_to, #redirected_to_method_params, #session, #template

Instance Method Summary collapse

Methods inherited from AbstractResponse

#redirect

Constructor Details

#initialize(cgi) ⇒ CgiResponse

Returns a new instance of CgiResponse.



114
115
116
117
# File 'lib/action_controller/cgi_process.rb', line 114

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

Instance Method Details

#outObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/action_controller/cgi_process.rb', line 119

def out
  convert_content_type!(@headers)
  $stdout.binmode if $stdout.respond_to?(:binmode)
  $stdout.sync = false
  
  begin
    print @cgi.header(@headers)

    if @cgi.send(:env_table)['REQUEST_METHOD'] == 'HEAD'
      return
    elsif @body.respond_to?(:call)
      @body.call(self)
    else
      print @body
    end
  rescue Errno::EPIPE => e
    # lost connection to the FCGI process -- ignore the output, then
  end
end