Class: Billy::ProxyConnection

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Deferrable
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.



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

def cache
  @cache
end

#handlerObject

Returns the value of attribute handler.



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

def handler
  @handler
end

Instance Method Details

#on_body(chunk) ⇒ Object



32
33
34
# File 'lib/billy/proxy_connection.rb', line 32

def on_body(chunk)
  @body << chunk
end

#on_headers_complete(headers) ⇒ Object



28
29
30
# File 'lib/billy/proxy_connection.rb', line 28

def on_headers_complete(headers)
  @headers = headers
end

#on_message_beginObject



23
24
25
26
# File 'lib/billy/proxy_connection.rb', line 23

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

#on_message_completeObject



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

def on_message_complete
  if @parser.http_method == 'CONNECT'
    restart_with_ssl(@parser.request_url)
  else
    if defined?(@ssl) && @ssl
      uri = Addressable::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



15
16
17
# File 'lib/billy/proxy_connection.rb', line 15

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

#receive_data(data) ⇒ Object



19
20
21
# File 'lib/billy/proxy_connection.rb', line 19

def receive_data(data)
  @parser << data
end