# class Camping::Server::XSendfile

### Public Class Methods

new(app) click to toggle source

    # File lib/camping/server.rb, line 258
    def initialize(app)
      @app = app
    end

### Public Instance Methods

call(env) click to toggle source

    # File lib/camping/server.rb, line 262
    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 276
    def size(str)
      str.bytesize
    end