Method: FTW::WebServer#handle_connection
- Defined in:
- lib/ftw/webserver.rb
#handle_connection(connection) ⇒ Object
Handle a new connection.
This method parses http requests and passes them on to #handle_request
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ftw/webserver.rb', line 44 def handle_connection(connection) while true begin request = (connection) rescue EOFError, Errno::EPIPE, Errno::ECONNRESET, HTTP::Parser::Error, IOError # Connection EOF'd or errored before we finished reading a full HTTP # message, shut it down. break rescue FTW::HTTP::Message::UnsupportedHTTPVersion break end if request["Content-Length"] || request["Transfer-Encoding"] request.body = connection end begin handle_request(request, connection) rescue => e puts e.inspect puts e.backtrace raise e end end connection.disconnect("Fun") end |