Class: Billy::ProxyConnection

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/billy/proxy_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



11
12
13
# File 'lib/billy/proxy_connection.rb', line 11

def cache
  @cache
end

#handlerObject

Returns the value of attribute handler.



10
11
12
# File 'lib/billy/proxy_connection.rb', line 10

def handler
  @handler
end

Instance Method Details

#on_body(chunk) ⇒ Object



30
31
32
# File 'lib/billy/proxy_connection.rb', line 30

def on_body(chunk)
  @body << chunk
end

#on_headers_complete(headers) ⇒ Object



26
27
28
# File 'lib/billy/proxy_connection.rb', line 26

def on_headers_complete(headers)
  @headers = headers
end

#on_message_beginObject



21
22
23
24
# File 'lib/billy/proxy_connection.rb', line 21

def on_message_begin
  @headers = nil
  @body = ''
end

#on_message_completeObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/billy/proxy_connection.rb', line 34

def on_message_complete
  if @parser.http_method == 'CONNECT'
    restart_with_ssl(@parser.request_url)
  else
    if @ssl
      uri = URI.parse(@parser.request_url)
      @url = "https://#{@ssl}#{[uri.path,uri.query].compact.join('?')}"
    else
      @url = @parser.request_url
    end
    handle_request
  end
end

#post_initObject



13
14
15
# File 'lib/billy/proxy_connection.rb', line 13

def post_init
  @parser = Http::Parser.new(self)
end

#receive_data(data) ⇒ Object



17
18
19
# File 'lib/billy/proxy_connection.rb', line 17

def receive_data(data)
  @parser << data
end