Class: Rack::Adapter::Rails::CGIWrapper

### Home Classes Methods

### In Files

- lib/rack/adapter/rails.rb

### Parent

CGI

### Methods

- ::new
- #args
- #cookies
- #env_table
- #header
- #params
- #query_string
- #stdinput
- #stdoutput

### Class/Module Index

Quicksearch

- Thin
- Thin::Backends
- Thin::Backends::Base
- Thin::Backends::SwiftiplyClient
- Thin::Backends::TcpServer
- Thin::Backends::UnixServer
- Thin::Command
- Thin::Connection
- Thin::Controllers
- Thin::Controllers::Cluster
- Thin::Controllers::Controller
- Thin::Controllers::Service
- Thin::Daemonizable
- Thin::Daemonizable::ClassMethods
- Thin::Headers
- Thin::InvalidOption
- Thin::InvalidRequest
- Thin::Logging
- Thin::Logging::SimpleFormatter
- Thin::OptionRequired
- Thin::PidFileExist
- Thin::PidFileNotFound
- Thin::PlatformNotSupported
- Thin::Request
- Thin::Response
- Thin::RestartTimeout
- Thin::Runner
- Thin::RunnerError
- Thin::Server
- Thin::Stats
- Thin::Stats::Adapter
- Thin::SwiftiplyConnection
- Thin::UnixConnection
- Rack
- Rack::Adapter
- Rack::Adapter::Rails
- Rack::Adapter::Rails::CGIWrapper
- Rack::Adapter::Rails::CgiApp
- Rack::AdapterNotFound
- Process

No matching classes.

# Rack::Adapter::Rails::CGIWrapper

### Public Class Methods

new(request, response, *args) click to toggle source

    # File lib/rack/adapter/rails.rb, line 91
    def initialize(request, response, *args)
      @request  = request
      @response = response
      @args     = *args
      @input    = request.body

      super *args
    end

### Public Instance Methods

args() click to toggle source

Used to wrap the normal args variable used inside CGI.

    # File lib/rack/adapter/rails.rb, line 157
    def args
      @args
    end

cookies() click to toggle source

    # File lib/rack/adapter/rails.rb, line 148
    def cookies
      @request.cookies
    end

env_table() click to toggle source

Used to wrap the normal env_table variable used inside CGI.

    # File lib/rack/adapter/rails.rb, line 162
    def env_table
      @request.env
    end

header(options = 'text/html') click to toggle source

    # File lib/rack/adapter/rails.rb, line 100
    def header(options = 'text/html')
      if options.is_a?(String)
        @response['Content-Type']     = options unless @response['Content-Type']
      else
        @response['Content-Length']   = options.delete('Content-Length').to_s if options['Content-Length']

        @response['Content-Type']     = options.delete('type') || "text/html"
        @response['Content-Type']    += '; charset=' + options.delete('charset') if options['charset']

        @response['Content-Language'] = options.delete('language') if options['language']
        @response['Expires']          = options.delete('expires') if options['expires']

        @response.status              = options.delete('Status') if options['Status']

        # Convert 'cookie' header to 'Set-Cookie' headers.
        # Because Set-Cookie header can appear more the once in the response body,
        # we store it in a line break seperated string that will be translated to
        # multiple Set-Cookie header by the handler.
        if cookie = options.delete('cookie')
          cookies = []

          case cookie
            when Array then cookie.each { |c| cookies << c.to_s }
            when Hash  then cookie.each { |_, c| cookies << c.to_s }
            else            cookies << cookie.to_s
          end

          @output_cookies.each { |c| cookies << c.to_s } if @output_cookies

          @response['Set-Cookie'] = [@response['Set-Cookie'], cookies].compact
          # See http://groups.google.com/group/rack-devel/browse_thread/thread/e8759b91a82c5a10/a8dbd4574fe97d69?#a8dbd4574fe97d69
          if Thin.ruby_18?
            @response['Set-Cookie'].flatten!
          else
            @response['Set-Cookie'] = @response['Set-Cookie'].join("\n")
          end
        end

        options.each { |k, v| @response[k] = v }
      end

      ''
    end

params() click to toggle source

    # File lib/rack/adapter/rails.rb, line 144
    def params
      @params ||= @request.params
    end

query_string() click to toggle source

    # File lib/rack/adapter/rails.rb, line 152
    def query_string
      @request.query_string
    end

stdinput() click to toggle source

Used to wrap the normal stdinput variable used inside CGI.

    # File lib/rack/adapter/rails.rb, line 167
    def stdinput
      @input
    end

stdoutput() click to toggle source

    # File lib/rack/adapter/rails.rb, line 171
    def stdoutput
      STDERR.puts 'stdoutput should not be used.'
      @response.body
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.