Class: EvilProxy::HTTPProxyServer

Inherits:
WEBrick::HTTPProxyServer
  • Object
show all
Defined in:
lib/evil-proxy/httpproxy.rb

Constant Summary collapse

VALID_CALBACKS =
Array.new
DEFAULT_CALLBACKS =
Hash.new

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ HTTPProxyServer

Returns a new instance of HTTPProxyServer.



8
9
10
11
12
# File 'lib/evil-proxy/httpproxy.rb', line 8

def initialize *args
  initialize_callbacks
  fire :when_initialize, *args
  super
end

Instance Method Details

#fire(key, *args) ⇒ Object



23
24
25
26
27
28
# File 'lib/evil-proxy/httpproxy.rb', line 23

def fire key, *args
  return unless @callbacks[key]
  @callbacks[key].each do |callback|
    instance_exec *args, &callback
  end
end

#proxy_service(req, res) ⇒ Object



30
31
32
33
34
# File 'lib/evil-proxy/httpproxy.rb', line 30

def proxy_service req, res
  fire :before_request, req
  super
  fire :before_response, req, res
end

#startObject



14
15
16
17
18
19
20
21
# File 'lib/evil-proxy/httpproxy.rb', line 14

def start
  begin
    fire :when_start
    super
  ensure
    fire :when_shutdown
  end
end