DEPLOY FAQ HACKING LICENSE NEWS README SIGNALS Sandbox Static_Files Summary TUNING Test_Suite rainbows_1 vs_Unicorn
Rainbows ActorSpawn AppPool Base Configurator Coolio CoolioThreadPool CoolioThreadSpawn DevFdResponse Epoll EventMachine FiberPool FiberSpawn MaxBody NeverBlock Rev RevFiberSpawn RevThreadPool RevThreadSpawn Revactor Sendfile ServerToken StreamResponseEpoll ThreadPool ThreadSpawn ThreadTimeout WriterThreadPool WriterThreadSpawn XEpoll XEpollThreadPool XEpollThreadSpawn

class Rainbows::Sendfile

This middleware handles X-Sendfile headers generated by applications or middlewares down the stack. It should be placed at the top (outermost layer) of the middleware stack to avoid having its to_path method clobbered by another middleware.

This converts X-Sendfile responses to bodies which respond to the to_path method which allows certain concurrency models to serve efficiently using sendfile() or similar. With multithreaded models under Ruby 1.9, IO.copy_stream will be used.

This middleware is the opposite of Rack::Sendfile as it reverses the effect of Rack:::Sendfile. Unlike many Ruby web servers, some configurations of Rainbows! are capable of serving static files efficiently.

Compatibility (via IO.copy_stream in Ruby 1.9):

Compatibility (Ruby 1.8 and 1.9)

DO NOT use this middleware if you're proxying to Rainbows! with a server that understands X-Sendfile (e.g. Apache, Lighttpd) natively.

This does NOT understand X-Accel-Redirect headers intended for nginx. X-Accel-Redirect requires the application to be highly coupled with the corresponding nginx configuration, and is thus too complicated to be worth supporting.


use Rainbows::Sendfile
run lambda { |env|
  path = "#{Dir.pwd}/random_blob"
  [ 200,
      'X-Sendfile' => path,
      'Content-Type' => 'application/octet-stream'

Pages Classes Methods

mail archives:
source code: git clone
	torsocks git clone http://ou63pmih66umazou.onion/rainbows.git