class Camping::Server::XSendfile
Public Class Methods
new(app)
click to toggle source
# File lib/camping/server.rb, line 278 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/camping/server.rb, line 282 def call(env) status, headers, body = @app.call(env) if key = headers.keys.grep(/X-Sendfile/i).first filename = headers[key] content = open(filename,'rb') { | io | io.read} headers['Content-Length'] = size(content).to_s body = [content] end return status, headers, body end
size(str)
click to toggle source
# File lib/camping/server.rb, line 296 def size(str) str.bytesize end