Class Camping::Server::XSendfile
In: lib/camping/server.rb
Parent: Object

A Rack middleware for reading X-Sendfile. Should only be used in development.

Methods

call   new  

Constants

HEADERS = [ "X-Sendfile", "X-Accel-Redirect", "X-LIGHTTPD-send-file"

Public Class methods

[Source]

     # File lib/camping/server.rb, line 164
164:     def initialize(app)
165:       @app = app
166:     end

Public Instance methods

[Source]

     # File lib/camping/server.rb, line 168
168:     def call(env)
169:       status, headers, body = @app.call(env)
170:       headers = Rack::Utils::HeaderHash.new(headers)
171:       if header = HEADERS.detect { |header| headers.include?(header) }
172:         path = headers[header]
173:         body = File.read(path)
174:         headers['Content-Length'] = body.length.to_s
175:       end
176:       [status, headers, body]
177:     end

[Validate]