Class: AgileProxy::ProxyConnection

Inherits:
Goliath::Connection
  • Object
show all
Defined in:
lib/agile_proxy/proxy_connection.rb

Overview

The Proxy Connection

This class is the event machine connection used by the proxy. Every request creates a new instance of this

Instance Method Summary collapse

Instance Method Details

#loggerObject



14
15
16
# File 'lib/agile_proxy/proxy_connection.rb', line 14

def logger
  ::AgileProxy.config.logger
end

#on_body(chunk) ⇒ Object



37
38
39
# File 'lib/agile_proxy/proxy_connection.rb', line 37

def on_body(chunk)
  @body << chunk
end

#on_headers_complete(headers) ⇒ Object



33
34
35
# File 'lib/agile_proxy/proxy_connection.rb', line 33

def on_headers_complete(headers)
  @headers = headers
end

#on_message_beginObject



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

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

#on_message_completeObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/agile_proxy/proxy_connection.rb', line 41

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

#post_initObject



17
18
19
20
21
# File 'lib/agile_proxy/proxy_connection.rb', line 17

def post_init
  super
  #@proxy_parser = Http::Parser.new(self)
  @proxy_parser = Http::Parser.new
end

#receive_data(data) ⇒ Object



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

def receive_data(data)
  #@proxy_parser << data
  @parser << data
end