Class: ActionController::CgiResponse

Inherits:
AbstractResponse
  • Object
show all
Defined in:
lib/web/shim/rails.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(cgi) ⇒ CgiResponse

Returns a new instance of CgiResponse.



138
139
140
141
# File 'lib/web/shim/rails.rb', line 138

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

Instance Method Details

#out(output = $stdout) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/web/shim/rails.rb', line 143

def out(output = $stdout)
  convert_content_type!(@headers)
  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)
      @body.call(self)
    else
      output.write(@body)
    end

    output.flush if output.respond_to?(:flush)
  rescue Errno::EPIPE => e
    # lost connection to the FCGI process -- ignore the output, then
  end
end