Class: Camping::Server::XSendfile

### Home Classes Methods

### In Files

- lib/camping/server.rb

### Parent

Object

### Methods

- ::new
- #call
- #size

### Files

- CHANGELOG
- COPYING

### Class/Module Index

Quicksearch

- Camping
- Camping::Base
- Camping::Controllers
- Camping::Cookies
- Camping::H
- Camping::Helpers
- Camping::Models
- Camping::Models::Base
- Camping::Reloader
- Camping::Server
- Camping::Server::Options
- Camping::Server::XSendfile
- Camping::Session
- Camping::Views
- Camping::X

No matching classes.

# Camping::Server::XSendfile

### Public Class Methods

new(app) click to toggle source

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

### Public Instance Methods

call(env) click to toggle source

    # File lib/camping/server.rb, line 174
    def call(env)
      status, headers, body = @app.call(env)

      if key = headers.keys.grep(/X-Sendfile/).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 188
    def size(str)
      str.bytesize
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.