Created
October 12, 2009 07:02
-
-
Save youpy/208203 to your computer and use it in GitHub Desktop.
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
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