/examples/webstack/lib/fix_lighttpd_fcgi.rb
https://github.com/MagLev/maglev · Ruby · 19 lines · 10 code · 1 blank · 8 comment · 0 complexity · b3477e57a37c9f3aea981436e2af39ee MD5 · raw file
- # Rack middleware that works around a bug in how Lighttpd + FastCGI handles
- # SCRIPT_NAME and PATH_INFO.
- #
- # What the app expects is for PATH_INFO to be something like "/app/home".
- # Lighttpd sets PATH_INFO to be "/home" and SCRIPT_NAME to "/app", which
- # confuses Rack URLMap with the map Sinatra gives it. So, I re-write
- # PATH_INFO here.
- #
- class FixLighttpdFastCGI
- def initialize(app)
- @app = app
- end
- def call(env)
- env['PATH_INFO'] = env['SCRIPT_NAME'] + env['PATH_INFO']
- env['SCRIPT_NAME'] = ''
- @app.call env
- end
- end