Class: Billy::ProxyConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Billy::ProxyConnection
- Defined in:
- lib/billy/proxy_connection.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
Instance Method Summary collapse
- #on_body(chunk) ⇒ Object
- #on_headers_complete(headers) ⇒ Object
- #on_message_begin ⇒ Object
- #on_message_complete ⇒ Object
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
8 9 10 |
# File 'lib/billy/proxy_connection.rb', line 8 def handler @handler end |
Instance Method Details
#on_body(chunk) ⇒ Object
40 41 42 |
# File 'lib/billy/proxy_connection.rb', line 40 def on_body(chunk) @body << chunk end |
#on_headers_complete(headers) ⇒ Object
36 37 38 |
# File 'lib/billy/proxy_connection.rb', line 36 def on_headers_complete(headers) @headers = headers end |
#on_message_begin ⇒ Object
31 32 33 34 |
# File 'lib/billy/proxy_connection.rb', line 31 def @headers = nil @body = '' end |
#on_message_complete ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/billy/proxy_connection.rb', line 44 def if @parser.http_method == 'CONNECT' restart_with_ssl(@parser.request_url) else if @ssl @url = "https://#{@ssl}#{@parser.request_url}" else @url = @parser.request_url end handle_request end end |
#post_init ⇒ Object
10 11 12 13 |
# File 'lib/billy/proxy_connection.rb', line 10 def post_init @parser = Http::Parser.new(self) @header_data = "" end |
#receive_data(data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/billy/proxy_connection.rb', line 15 def receive_data(data) @header_data << data if @headers.nil? begin @parser << data rescue HTTP::Parser::Error if @parser.http_method == 'CONNECT' # work-around for CONNECT requests until https://github.com/tmm1/http_parser.rb/pull/15 gets merged if @header_data.end_with?("\r\n\r\n") restart_with_ssl(@header_data.split("\r\n").first.split(/\s+/)[1]) end else close_connection end end end |