Class: Mongrel::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/pdtp/common/http_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pendingObject

A flag to prevent response.finished from being called automatically



162
163
164
# File 'lib/pdtp/common/http_server.rb', line 162

def pending
  @pending
end

Instance Method Details

#close_connection_after_writingObject



181
182
183
# File 'lib/pdtp/common/http_server.rb', line 181

def close_connection_after_writing
  @socket.close_connection_after_writing
end

#finishedObject



191
192
193
194
195
196
# File 'lib/pdtp/common/http_server.rb', line 191

def finished
  send_status
  send_header
  send_body
  @socket.close_connection_after_writing
end

#send_file(path, small_file = false) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/pdtp/common/http_server.rb', line 164

def send_file(path, small_file = false)
  File.open(path, "rb") do |f|
    while chunk = f.read(Const::CHUNK_SIZE) and chunk.length > 0
      begin
        write(chunk)
      rescue Object => exc
        break
      end
    end
  end
  @body_sent = true
end

#socket_error(details) ⇒ Object



185
186
187
188
189
# File 'lib/pdtp/common/http_server.rb', line 185

def socket_error(details)
  @socket.close_connection
  done = true
  raise details
end

#write(data) ⇒ Object



177
178
179
# File 'lib/pdtp/common/http_server.rb', line 177

def write(data)
  @socket.send_data data
end