Class: Rackdapter::InboundProxyConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Rackdapter::InboundProxyConnection
- Defined in:
- lib/rackdapter/proxy.rb
Instance Method Summary collapse
- #client_connection=(con) ⇒ Object
- #close ⇒ Object
-
#initialize(*args) ⇒ InboundProxyConnection
constructor
A new instance of InboundProxyConnection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #send(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(*args) ⇒ InboundProxyConnection
Returns a new instance of InboundProxyConnection.
5 6 7 8 |
# File 'lib/rackdapter/proxy.rb', line 5 def initialize(*args) @app = args.first super end |
Instance Method Details
#client_connection=(con) ⇒ Object
10 11 12 |
# File 'lib/rackdapter/proxy.rb', line 10 def client_connection=(con) @request = con end |
#close ⇒ Object
38 39 40 |
# File 'lib/rackdapter/proxy.rb', line 38 def close close_connection_after_writing end |
#post_init ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rackdapter/proxy.rb', line 14 def post_init host,port = "127.0.0.1", @app.next_port EventMachine::connect host, port, OutboundProxyConnection, self @receive_buffer = "" @connected = false end |
#receive_data(data) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rackdapter/proxy.rb', line 21 def receive_data(data) @receive_buffer << data if @connected send data else if @request @connected = true send @receive_buffer end end end |
#send(data) ⇒ Object
33 34 35 36 |
# File 'lib/rackdapter/proxy.rb', line 33 def send(data) # puts "sending to client: #{data}\n---\n" @request.send_data(data) end |
#unbind ⇒ Object
42 43 44 |
# File 'lib/rackdapter/proxy.rb', line 42 def unbind close_connection end |