Class: Mongrel::HttpResponse
- Inherits:
-
Object
- Object
- Mongrel::HttpResponse
- Defined in:
- lib/pdtp/common/http_server.rb
Instance Attribute Summary collapse
-
#pending ⇒ Object
A flag to prevent response.finished from being called automatically.
Instance Method Summary collapse
- #close_connection_after_writing ⇒ Object
- #finished ⇒ Object
- #send_file(path, small_file = false) ⇒ Object
- #socket_error(details) ⇒ Object
- #write(data) ⇒ Object
Instance Attribute Details
#pending ⇒ Object
A flag to prevent response.finished from being called automatically
157 158 159 |
# File 'lib/pdtp/common/http_server.rb', line 157 def pending @pending end |
Instance Method Details
#close_connection_after_writing ⇒ Object
176 177 178 |
# File 'lib/pdtp/common/http_server.rb', line 176 def close_connection_after_writing @socket.close_connection_after_writing end |
#finished ⇒ Object
186 187 188 189 190 191 |
# File 'lib/pdtp/common/http_server.rb', line 186 def finished send_status send_header send_body @socket.close_connection_after_writing end |
#send_file(path, small_file = false) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/pdtp/common/http_server.rb', line 159 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
180 181 182 183 184 |
# File 'lib/pdtp/common/http_server.rb', line 180 def socket_error(details) @socket.close_connection done = true raise details end |
#write(data) ⇒ Object
172 173 174 |
# File 'lib/pdtp/common/http_server.rb', line 172 def write(data) @socket.send_data data end |