PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1
  1. # Rack middleware that works around a bug in how Lighttpd + FastCGI handles
  2. # SCRIPT_NAME and PATH_INFO.
  3. #
  4. # What the app expects is for PATH_INFO to be something like "/app/home".
  5. # Lighttpd sets PATH_INFO to be "/home" and SCRIPT_NAME to "/app", which
  6. # confuses Rack URLMap with the map Sinatra gives it. So, I re-write
  7. # PATH_INFO here.
  8. #
  9. class FixLighttpdFastCGI
  10. def initialize(app)
  11. @app = app
  12. end
  13. def call(env)
  14. env['PATH_INFO'] = env['SCRIPT_NAME'] + env['PATH_INFO']
  15. env['SCRIPT_NAME'] = ''
  16. @app.call env
  17. end
  18. end