Class: Gopher::Connection
- Defined in:
- lib/gopher.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
Instance Method Summary collapse
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
248 249 250 |
# File 'lib/gopher.rb', line 248 def application @application end |
Instance Method Details
#receive_data(data) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/gopher.rb', line 250 def receive_data(data) begin raise InvalidRequest if data.length > 255 response = application.request(data) case response when String then send_data(response) when StringIO then send_data(response.read) when File while chunk = response.read(8192) do send_data(chunk) end end close_connection_after_writing rescue Gopher::NotFound send_data "not found" close_connection_after_writing rescue => e close_connection raise e end end |