Module: CGI::QueryExtension

Included in:
CGI
Defined in:
lib/cgialt/core.rb

Overview

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.

Defined Under Namespace

Modules: Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cookiesObject

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



951
952
953
# File 'lib/cgialt/core.rb', line 951

def cookies
  @cookies
end

#paramsObject

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



958
959
960
# File 'lib/cgialt/core.rb', line 958

def params
  @params
end

Instance Method Details

#[](key) ⇒ Object

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.



1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/cgialt/core.rb', line 1318

def [](key)
  params = @params[key]
  value = params[0]
  if @multipart
    return value if value
    return defined?(StringIO) ? StringIO.new('') : Tempfile.new('CGI')
  else
    str = value ? value.dup : ''
    str.extend(Value)
    str.set_params(params)
    return str
  end
end

#acceptObject

return ENV



877
# File 'lib/cgialt/core.rb', line 877

def accept            ; return ENV['HTTP_ACCEPT']          ; end

#accept_charsetObject

return ENV



880
# File 'lib/cgialt/core.rb', line 880

def accept_charset    ; return ENV['HTTP_ACCEPT_CHARSET']  ; end

#accept_encodingObject

return ENV



883
# File 'lib/cgialt/core.rb', line 883

def accept_encoding   ; return ENV['HTTP_ACCEPT_ENCODING'] ; end

#accept_languageObject

return ENV



886
# File 'lib/cgialt/core.rb', line 886

def accept_language   ; return ENV['HTTP_ACCEPT_LANGUAGE'] ; end

#auth_typeObject

return ENV



832
# File 'lib/cgialt/core.rb', line 832

def auth_type         ; return ENV['AUTH_TYPE']            ; end

#cache_controlObject

return ENV



889
# File 'lib/cgialt/core.rb', line 889

def cache_control     ; return ENV['HTTP_CACHE_CONTROL']   ; end

#content_lengthObject

return Integer(ENV)



826
# File 'lib/cgialt/core.rb', line 826

def content_length    ; return Integer(ENV['CONTENT_LENGTH']) ; end

#content_typeObject

return ENV



835
# File 'lib/cgialt/core.rb', line 835

def content_type      ; return ENV['CONTENT_TYPE']         ; end

#create_body(is_large) ⇒ Object

:nodoc:



1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
# File 'lib/cgialt/core.rb', line 1050

def create_body(is_large)  #:nodoc:
  if is_large
    require 'tempfile'
    body = Tempfile.new('CGI')
  else
    begin
      require 'stringio'
      body = StringIO.new
    rescue LoadError
      require 'tempfile'
      body = Tempfile.new('CGI')
    end
  end
  body.binmode if defined? body.binmode
  return body
end

#fromObject

return ENV



892
# File 'lib/cgialt/core.rb', line 892

def from              ; return ENV['HTTP_FROM']            ; end

#gateway_interfaceObject

return ENV



838
# File 'lib/cgialt/core.rb', line 838

def gateway_interface ; return ENV['GATEWAY_INTERFACE']    ; end

#has_key?(*args) ⇒ Boolean Also known as: key?, include?

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

Returns:

  • (Boolean)


1358
1359
1360
# File 'lib/cgialt/core.rb', line 1358

def has_key?(*args)
  @params.has_key?(*args)
end

#hostObject

return ENV



895
# File 'lib/cgialt/core.rb', line 895

def host              ; return ENV['HTTP_HOST']            ; end

#keys(*args) ⇒ Object

Return all parameter keys as an array.



1353
1354
1355
# File 'lib/cgialt/core.rb', line 1353

def keys(*args)
  @params.keys(*args)
end

#multipart?Boolean

*** original *def initialize_query()

*

*end *private :initialize_query *** /original

Returns:

  • (Boolean)


1287
1288
1289
# File 'lib/cgialt/core.rb', line 1287

def multipart?
  @multipart
end

#negotiateObject

return ENV



898
# File 'lib/cgialt/core.rb', line 898

def negotiate         ; return ENV['HTTP_NEGOTIATE']       ; end

#path_infoObject

return ENV



841
# File 'lib/cgialt/core.rb', line 841

def path_info         ; return ENV['PATH_INFO']            ; end

#path_translatedObject

return ENV



844
# File 'lib/cgialt/core.rb', line 844

def path_translated   ; return ENV['PATH_TRANSLATED']      ; end

#pragmaObject

return ENV



901
# File 'lib/cgialt/core.rb', line 901

def pragma            ; return ENV['HTTP_PRAGMA']          ; end

#query_stringObject

return ENV



847
# File 'lib/cgialt/core.rb', line 847

def query_string      ; return ENV['QUERY_STRING']         ; end

Get the raw cookies as a string.



931
932
933
# File 'lib/cgialt/core.rb', line 931

def raw_cookie
  return ENV['HTTP_COOKIE']
end

#raw_cookie2Object

Get the raw RFC2965 cookies as a string.



941
942
943
# File 'lib/cgialt/core.rb', line 941

def raw_cookie2
  return ENV['HTTP_COOKIE2']
end

#refererObject

return ENV



904
# File 'lib/cgialt/core.rb', line 904

def referer           ; return ENV['HTTP_REFERER']         ; end

#remote_addrObject

return ENV



850
# File 'lib/cgialt/core.rb', line 850

def remote_addr       ; return ENV['REMOTE_ADDR']          ; end

#remote_hostObject

return ENV



853
# File 'lib/cgialt/core.rb', line 853

def remote_host       ; return ENV['REMOTE_HOST']          ; end

#remote_identObject

return ENV



856
# File 'lib/cgialt/core.rb', line 856

def remote_ident      ; return ENV['REMOTE_IDENT']         ; end

#remote_userObject

return ENV



859
# File 'lib/cgialt/core.rb', line 859

def remote_user       ; return ENV['REMOTE_USER']          ; end

#request_methodObject

return ENV



862
# File 'lib/cgialt/core.rb', line 862

def request_method    ; return ENV['REQUEST_METHOD']       ; end

#script_nameObject

return ENV



865
# File 'lib/cgialt/core.rb', line 865

def script_name       ; return ENV['SCRIPT_NAME']          ; end

#server_nameObject

return ENV



868
# File 'lib/cgialt/core.rb', line 868

def server_name       ; return ENV['SERVER_NAME']          ; end

#server_portObject

return Integer(ENV)



829
# File 'lib/cgialt/core.rb', line 829

def server_port       ; return Integer(ENV['SERVER_PORT'])    ; end

#server_protocolObject

return ENV



871
# File 'lib/cgialt/core.rb', line 871

def server_protocol   ; return ENV['SERVER_PROTOCOL']      ; end

#server_softwareObject

return ENV



874
# File 'lib/cgialt/core.rb', line 874

def server_software   ; return ENV['SERVER_SOFTWARE']      ; end

#unescape_filename?Boolean

:nodoc:

Returns:

  • (Boolean)


1066
1067
1068
1069
# File 'lib/cgialt/core.rb', line 1066

def unescape_filename?  #:nodoc:
  user_agent = ENV['HTTP_USER_AGENT']
  return /Mac/ni.match(user_agent) && /Mozilla/ni.match(user_agent) && !/MSIE/ni.match(user_agent)
end

#user_agentObject

return ENV



907
# File 'lib/cgialt/core.rb', line 907

def user_agent        ; return ENV['HTTP_USER_AGENT']      ; end