0
@@ -12,127 +12,124 @@ require 'rack'
0
# root: Root directory of the Rails app
0
# env: Rails environment to run in (development, production or test)
0
# Based on http://fuzed.rubyforge.org/ Rails adapter
0
- def initialize(options={})
0
- @root = options[:root] || Dir.pwd
0
- @env = options[:env] || 'development'
0
- @file_server = Rack::File.new(::File.join(RAILS_ROOT, "public"))
0
- ENV['RAILS_ENV'] = @env
0
+ def initialize(options={})
0
+ @root = options[:root] || Dir.pwd
0
+ @env = options[:env] || 'development'
0
+ @file_server = Rack::File.new(::File.join(RAILS_ROOT, "public"))
0
+ ENV['RAILS_ENV'] = @env
0
- require "#{@root}/config/environment"
0
- # TODO refactor this in File#can_serve?(path) ??
0
- full_path = ::File.join(@file_server.root, Utils.unescape(path))
0
- ::File.file?(full_path) && ::File.readable?(full_path)
0
- # Serve the file if it's there
0
- return @file_server.call(env) if file?(env['PATH_INFO'])
0
- request = Request.new(env)
0
- response = Response.new
0
- session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
0
- cgi = CGIWrapper.new(request, response)
0
+ require "#{@root}/config/environment"
0
+ # TODO refactor this in File#can_serve?(path) ??
0
+ full_path = ::File.join(@file_server.root, Utils.unescape(path))
0
+ ::File.file?(full_path) && ::File.readable?(full_path)
0
+ # Serve the file if it's there
0
+ return @file_server.call(env) if file?(env['PATH_INFO'])
0
+ request = Request.new(env)
0
+ response = Response.new
0
- Dispatcher.dispatch(cgi, session_options, response)
0
+ session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
0
+ cgi = CGIWrapper.new(request, response)
0
+ Dispatcher.dispatch(cgi, session_options, response)
0
- class CGIWrapper < ::CGI
0
- def initialize(request, response, *args)
0
+ class CGIWrapper < ::CGI
0
+ def initialize(request, response, *args)
0
+ def header(options = "text/html")
0
+ if options.is_a?(String)
0
+ @response['Content-Type'] = options unless @response['Content-Type']
0
+ @response['Content-Length'] = options.delete('Content-Length').to_s if options['Content-Length']
0
- def header(options = "text/html")
0
- if options.is_a?(String)
0
- @response['Content-Type'] = options unless @response['Content-Type']
0
- @response['Content-Length'] = options.delete('Content-Length').to_s if options['Content-Length']
0
- @response['Content-Type'] = options.delete('type') || "text/html"
0
- @response['Content-Type'] += "; charset=" + options.delete('charset') if options['charset']
0
- @response['Content-Language'] = options.delete('language') if options['language']
0
- @response['Expires'] = options.delete('expires') if options['expires']
0
+ @response['Content-Type'] = options.delete('type') || "text/html"
0
+ @response['Content-Type'] += "; charset=" + options.delete('charset') if options['charset']
0
+ @response['Content-Language'] = options.delete('language') if options['language']
0
+ @response['Expires'] = options.delete('expires') if options['expires']
0
- @response.status = options.delete('Status') if options['Status']
0
- options.each { |k,v| @response[k] = v }
0
- # Convert 'cookie' header to 'Set-Cookie' headers.
0
- # According to http://www.faqs.org/rfcs/rfc2109.html:
0
- # the Set-Cookie response header comprises the token
0
- # Set-Cookie:, followed by a comma-separated list of
0
- # one or more cookies.
0
- if cookie = @response.header.delete('Cookie')
0
- when Array then cookie.collect { |c| c.to_s }.join(', ')
0
- when Hash then cookie.collect { |_, c| c.to_s }.join(', ')
0
+ @response.status = options.delete('Status') if options['Status']
0
+ options.each { |k,v| @response[k] = v }
0
- cookies << ', ' + @output_cookies.each { |c| c.to_s }.join(', ') if @output_cookies
0
- @response['Set-Cookie'] = cookies
0
+ # Convert 'cookie' header to 'Set-Cookie' headers.
0
+ # According to http://www.faqs.org/rfcs/rfc2109.html:
0
+ # the Set-Cookie response header comprises the token
0
+ # Set-Cookie:, followed by a comma-separated list of
0
+ # one or more cookies.
0
+ if cookie = @response.header.delete('Cookie')
0
+ when Array then cookie.collect { |c| c.to_s }.join(', ')
0
+ when Hash then cookie.collect { |_, c| c.to_s }.join(', ')
0
- @params ||= @request.params
0
- # Used to wrap the normal args variable used inside CGI.
0
- # Used to wrap the normal env_table variable used inside CGI.
0
+ cookies << ', ' + @output_cookies.each { |c| c.to_s }.join(', ') if @output_cookies
0
+ @response['Set-Cookie'] = cookies
0
- # Used to wrap the normal stdinput variable used inside CGI.
0
- STDERR.puts "stdoutput should not be used."
0
+ @params ||= @request.params
0
+ # Used to wrap the normal args variable used inside CGI.
0
+ # Used to wrap the normal env_table variable used inside CGI.
0
+ # Used to wrap the normal stdinput variable used inside CGI.
0
+ STDERR.puts "stdoutput should not be used."
Comments
No one has commented yet.