class EvilProxy::HTTPProxyServer
Constants
- DEFAULT_CALLBACKS
- SUPPORTED_METHODS
Attributes
callbacks[R]
Public Class Methods
define_callback_methods(callback)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 59 def self.define_callback_methods callback define_method callback do |&block| @callbacks[callback] ||= [] @callbacks[callback] << block end define_singleton_method callback do |&block| DEFAULT_CALLBACKS[callback] ||= [] DEFAULT_CALLBACKS[callback] << block end end
new(config = {})
click to toggle source
Calls superclass method
# File lib/evil-proxy/httpproxy.rb, line 11 def initialize config = {}, default = WEBrick::Config::HTTP initialize_callbacks config fire :when_initialize, config, default config.merge!( Logger: WEBrick::Log.new(nil, 0), AccessLog: [] ) if config[:Quiet] super end
Public Instance Methods
do_DELETE(req, res)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 77 def do_DELETE(req, res) perform_proxy_request(req, res) do |http, path, header| http.delete(path, header) end end
do_OPTIONS(_req, res)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 89 def do_OPTIONS(_req, res) res['allow'] = SUPPORTED_METHODS.join(',') end
do_PATCH(req, res)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 83 def do_PATCH(req, res) perform_proxy_request(req, res) do |http, path, header| http.patch(path, req.body || '', header) end end
do_PUT(req, res)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 71 def do_PUT(req, res) perform_proxy_request(req, res) do |http, path, header| http.put(path, req.body || '', header) end end
exit()
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 35 def exit self.logger.info "#{self.class}#exit: pid=#{$$}" Kernel.exit end
fire(key, *args)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 46 def fire key, *args return unless @callbacks[key] @callbacks[key].each do |callback| instance_exec *args, &callback end end
restart(&block)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 40 def restart &block self.logger.info "#{self.class}#restart: pid=#{$$}" if @status == :Running initialize_callbacks Hash.new instance_exec &block if block end
service(req, res)
click to toggle source
Calls superclass method
# File lib/evil-proxy/httpproxy.rb, line 53 def service req, res fire :before_request, req super fire :before_response, req, res end
start()
click to toggle source
Calls superclass method
# File lib/evil-proxy/httpproxy.rb, line 21 def start begin fire :when_start super ensure fire :when_shutdown end end
stop()
click to toggle source
Calls superclass method
# File lib/evil-proxy/httpproxy.rb, line 30 def stop self.logger.info "#{self.class}#stop: pid=#{$$}" super end
Private Instance Methods
initialize_callbacks(config)
click to toggle source
# File lib/evil-proxy/httpproxy.rb, line 117 def initialize_callbacks config @callbacks = Hash.new DEFAULT_CALLBACKS.each do |key, callbacks| @callbacks[key] = callbacks.clone end end