Class: Noder::HTTP::Connection
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Noder::HTTP::Connection
- Includes:
- EventMachine::HttpServer
- Defined in:
- lib/noder/http/connection.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#request_stack ⇒ Object
Returns the value of attribute request_stack.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Connection
constructor
A new instance of Connection.
- #post_init ⇒ Object
- #process_http_request ⇒ Object
- #request_env ⇒ Object
Constructor Details
#initialize(*args) ⇒ Connection
Returns a new instance of Connection.
11 12 13 14 |
# File 'lib/noder/http/connection.rb', line 11 def initialize(*args) super(*args) @settings = args[1] end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
9 10 11 |
# File 'lib/noder/http/connection.rb', line 9 def app @app end |
#environment ⇒ Object
Returns the value of attribute environment.
9 10 11 |
# File 'lib/noder/http/connection.rb', line 9 def environment @environment end |
#request_stack ⇒ Object
Returns the value of attribute request_stack.
9 10 11 |
# File 'lib/noder/http/connection.rb', line 9 def request_stack @request_stack end |
#settings ⇒ Object
Returns the value of attribute settings.
9 10 11 |
# File 'lib/noder/http/connection.rb', line 9 def settings @settings end |
Instance Method Details
#post_init ⇒ Object
16 17 18 19 20 21 |
# File 'lib/noder/http/connection.rb', line 16 def post_init super if settings[:enable_ssl] start_tls(:private_key_file => settings[:ssl_key], :cert_chain_file => settings[:ssl_cert], :verify_peer => false) end end |
#process_http_request ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/noder/http/connection.rb', line 23 def process_http_request env = { connection: self, request_env: request_env, request: nil, response: nil } EM.defer do request_stack.call(env) end end |
#request_env ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/noder/http/connection.rb', line 35 def request_env port, ip = Socket.unpack_sockaddr_in(get_peername) { request_method: @http_request_method, cookie: @http_cookie, content_type: @http_content_type, path_info: @http_path_info, request_uri: @http_request_uri, query_string: @http_query_string, post_content: @http_post_content, headers: @http_headers, protocol: @http_protocol, ip: ip } end |