Class: Billy::ProxyConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Billy::ProxyConnection
- Defined in:
- lib/billy/proxy_connection.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#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
#cache ⇒ Object
Returns the value of attribute cache.
10 11 12 |
# File 'lib/billy/proxy_connection.rb', line 10 def cache @cache end |
#handler ⇒ Object
Returns the value of attribute handler.
9 10 11 |
# File 'lib/billy/proxy_connection.rb', line 9 def handler @handler end |
Instance Method Details
#on_body(chunk) ⇒ Object
42 43 44 |
# File 'lib/billy/proxy_connection.rb', line 42 def on_body(chunk) @body << chunk end |
#on_headers_complete(headers) ⇒ Object
38 39 40 |
# File 'lib/billy/proxy_connection.rb', line 38 def on_headers_complete(headers) @headers = headers end |
#on_message_begin ⇒ Object
33 34 35 36 |
# File 'lib/billy/proxy_connection.rb', line 33 def @headers = nil @body = '' end |
#on_message_complete ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/billy/proxy_connection.rb', line 46 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
12 13 14 15 |
# File 'lib/billy/proxy_connection.rb', line 12 def post_init @parser = Http::Parser.new(self) @header_data = "" end |
#receive_data(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/billy/proxy_connection.rb', line 17 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 |