Skip to content

Instantly share code, notes, and snippets.

@mikolajb
Created January 15, 2010 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikolajb/277636 to your computer and use it in GitHub Desktop.
Save mikolajb/277636 to your computer and use it in GitHub Desktop.
require 'webrick/httpproxy'
require 'RMagick'
handler = Proc.new do |req,res|
if [".gif", ".png", ".jpg", ".jpeg", ".ico"].include? req.path[-4..-1]
begin
image = Magick::Image.from_blob(res.body).first
image.flip!
res.body = image.to_blob
rescue Magick::ImageMagickError => e
puts "#{req.path} error:#{e}"
end
end
end
server = WEBrick::HTTPProxyServer.new(:Port => 9090, :AccessLog => [],
:ProxyContentHandler => handler)
trap("INT") { server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment