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
162 163 164 |
# File 'lib/pdtp/common/http_server.rb', line 162 def pending @pending end |
Instance Method Details
#close_connection_after_writing ⇒ Object
181 182 183 |
# File 'lib/pdtp/common/http_server.rb', line 181 def close_connection_after_writing @socket.close_connection_after_writing end |
#finished ⇒ Object
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 |