In Files

  • cgi.rb

CGI::QueryExtension

Mixin module. It provides the follow functionality groups:

  1. Access to CGI environment variables as methods. See documentation to the CGI class for a list of these variables.

  2. Access to cookies, including the cookies attribute.

  3. Access to parameters, including the params attribute, and overloading

    to perform parameter value lookup by key.

  4. The initialize_query method, for initialising the above mechanisms, handling multipart forms, and allowing the class to be used in “offline” mode.

Attributes

cookies[RW]

Get the cookies as a hash of cookie-name=>Cookie pairs.

params[R]

Get the parameters as a hash of name=>values pairs, where values is an Array.

Public Instance Methods

[](key) click to toggle source

Get the value for the parameter with a given key.

If the parameter has multiple values, only the first will be retrieved; use params() to get the array of values.

 
               # File cgi.rb, line 1165
def [](key)
  params = @params[key]
  return '' unless params
  value = params[0]
  if @multipart
    if value
      return value
    elsif defined? StringIO
      StringIO.new("")
    else
      Tempfile.new("CGI")
    end
  else
    str = if value then value.dup else "" end
    str.extend(Value)
    str.set_params(params)
    str
  end
end
            
has_key?(*args) click to toggle source

Returns true if a given parameter key exists in the query.

 
               # File cgi.rb, line 1191
def has_key?(*args)
  @params.has_key?(*args)
end
            
Also aliased as: key?, include?
include?(*args) click to toggle source
Alias for: has_key?
key?(*args) click to toggle source
Alias for: has_key?
keys(*args) click to toggle source

Return all parameter keys as an array.

 
               # File cgi.rb, line 1186
def keys(*args)
  @params.keys(*args)
end
            
multipart?() click to toggle source
 
               # File cgi.rb, line 1134
def multipart?
  @multipart
end
            
params=(hash) click to toggle source

Set all the parameters.

 
               # File cgi.rb, line 964
def params=(hash)
  @params.clear
  @params.update(hash)
end
            
raw_cookie2() click to toggle source

Get the raw RFC2965 cookies as a string.

 
               # File cgi.rb, line 952
def raw_cookie2
  env_table["HTTP_COOKIE2"]
end