Class: Mongrel::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/packet_mongrel.rb,
lib/packet/packet_mongrel.rb

Instance Method Summary collapse

Instance Method Details

#close_connection_after_writingObject



165
166
167
# File 'lib/packet_mongrel.rb', line 165

def close_connection_after_writing
  @socket.close_connection
end

#finishedObject



175
176
177
178
179
180
# File 'lib/packet_mongrel.rb', line 175

def finished
  send_status
  send_header
  send_body
  @socket.close_connection
end

#send_file(path, small_file = false) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/packet_mongrel.rb', line 148

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



169
170
171
172
173
# File 'lib/packet_mongrel.rb', line 169

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

#write(data) ⇒ Object



161
162
163
# File 'lib/packet_mongrel.rb', line 161

def write(data)
  @socket.send_data data
end