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

Methods

call   new   size   size  

Public Class methods

[Source]

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

Public Instance methods

[Source]

     # File lib/camping/server.rb, line 174
174:       def call(env)
175:         status, headers, body = @app.call(env)
176:         
177:         if key = headers.keys.grep(/X-Sendfile/i).first
178:           filename = headers[key]
179:           content = open(filename,'rb') { | io | io.read}
180:           headers['Content-Length'] = size(content).to_s
181:           body = [content]
182:         end
183:         
184:         return status, headers, body
185:       end

[Source]

     # File lib/camping/server.rb, line 188
188:         def size(str)
189:           str.bytesize
190:         end

[Source]

     # File lib/camping/server.rb, line 192
192:         def size(str)
193:           str.size
194:         end

[Validate]