Skip to content

Instantly share code, notes, and snippets.

@jergason
Created August 10, 2011 08:37
Show Gist options
  • Save jergason/1136379 to your computer and use it in GitHub Desktop.
Save jergason/1136379 to your computer and use it in GitHub Desktop.
Checking size of each request
#in top of your app.rb file
require 'sinatra'
require 'response_size'
use Rack::ResponseSize
module Rack
# Save size of response
class ResponseSize
def initialize(app)
@app = app
end
def call(env)
response = @app.call(env)
File.open("size.log", "a") do |f|
# super ghetto
f.write "Response Size: #{Marshal.dump(response).length}"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment