| . |
|
Bitland.Net Security Notes
Comments? email jwilkins-at-bitland*net
More information on the author at Jonathan Wilkins's home page RSS feed available at http://www.bitland.net/index.rss |
| Archives: 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000 |
| |
| |
| Quick Proxy, or Why I Love Ruby pt 9215 | (2008/02/02 12:00) |
# Quick basic proxy, just strips accept-encoding header and dumps
# to files in the local directory using the WebScarab naming convention
# (0-request, 0-response ...)
require 'net/http'
require 'webrick/httpproxy'
s = WEBrick::HTTPProxyServer.new(
:Port => 9999,
:RequestCallback => Proc.new{|req,res|
$count ||= 0
req.header.delete('accept-encoding')
open("#{$count}-request", "wb+") { |f|
f << "#{req.request_line}#{req.raw_header}\r\n#{req.body}"
}
},
:ProxyContentHandler => Proc.new{|req,res|
open("#{$count}-response", "wb+") { |f|
f << res.status_line
res.header.keys.each { |k|
f << "#{k.capitalize}: #{res.header[k]}\r\n"
}
f << "\r\n#{res.body}"
}
$count += 1
}
);
trap("INT"){
s.shutdown
}
s.start
|
| +digg | +del.icio.us | [Ruby ] | Permanent link |
| |
| RSS feed available at http://www.bitland.net/index.rss |