Skip to content

Instantly share code, notes, and snippets.

@youpy
Created August 10, 2009 12:42
Show Gist options
  • Save youpy/165171 to your computer and use it in GitHub Desktop.
Save youpy/165171 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'webrick'
require 'webrick/httpproxy'
handler = Proc.new() do |req,res|
if (req.path == '/glm/mmap' and res['content-type'] =~ /binary/) ||
(req.host =~ /^cbk\d+\.google/ and res['content-type'] =~ /jpeg/)
res.body.gsub!(/0/m, rand(10).to_s)
res['cache-control'] = 'no-cache'
end
end
s = WEBrick::HTTPProxyServer.new(
:BindAddress => '0.0.0.0',
:Port => 8080,
:ProxyContentHandler => handler
)
Signal.trap('INT') do
s.shutdown
end
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment