Skip to content

Instantly share code, notes, and snippets.

@nicksieger
nicksieger / jruby-rack-x-sendfile.rb
Created May 5, 2011 22:22
X-Sendfile middleware for JRuby-Rack 1.0.8 or greater
class JRubyRackXSendfile
def initialize(app)
@app = app
end
def call(env)
result, headers, body = @app.call(env)
if headers['X-Sendfile']
[result, headers, File.new(headers.delete('X-Sendfile'))]
else
# escaping.txt
---
{ "value":"\u00B9"}
---
<div>&sup1;</div>
# url.txt
---