Skip to content

Instantly share code, notes, and snippets.

@youpy
Created October 12, 2009 07:02
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 youpy/208203 to your computer and use it in GitHub Desktop.
Save youpy/208203 to your computer and use it in GitHub Desktop.
module Rack
class Glitch
def initialize(app, options = {})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if headers['content-type'] =~ /jpeg/
response = glitch(response)
end
[status, headers, response]
end
private
def glitch(response)
body = ''
response.each do |res|
body += res
end
[body.gsub(/0/m, rand(10).to_s)]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment