Created
July 12, 2011 16:02
-
-
Save brianstorti/1078279 to your computer and use it in GitHub Desktop.
Ruby Script to Capture HTTP traffic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extracted from http://www.thekua.com/atwork/2011/07/ruby-script-to-capture-http-traffic/ | |
require 'webrick' | |
include WEBrick | |
class Simple < WEBrick::HTTPServlet::AbstractServlet | |
def do_POST(request, response) | |
puts "Body: " + request.body | |
puts "Header: " + request.raw_header.to_s | |
response.status = 200 | |
end | |
end | |
server = HTTPServer.new(:Port => 5899) | |
server.mount "/", Simple | |
['TERM', 'INT'].each do |signal| | |
trap(signal){ server.shutdown } | |
end | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment