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.



977
978
979
# File 'lib/cgialt/core.rb', line 977

def cookies
  @cookies
end

#paramsObject

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



984
985
986
# File 'lib/cgialt/core.rb', line 984

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.



1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
# File 'lib/cgialt/core.rb', line 1352

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



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

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

#accept_charsetObject

return ENV



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

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

#accept_encodingObject

return ENV



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

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

#accept_languageObject

return ENV



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

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

#auth_typeObject

return ENV



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

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

#cache_controlObject

return ENV



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

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

#content_lengthObject

return Integer(ENV)



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

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

#content_typeObject

return ENV



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

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

#create_body(is_large) ⇒ Object

:nodoc:



1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
# File 'lib/cgialt/core.rb', line 1083

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



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

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

#gateway_interfaceObject

return ENV



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

def gateway_interface ; return env_table['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)


1392
1393
1394
# File 'lib/cgialt/core.rb', line 1392

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

#hostObject

return ENV



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

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

#keys(*args) ⇒ Object

Return all parameter keys as an array.



1387
1388
1389
# File 'lib/cgialt/core.rb', line 1387

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

#multipart?Boolean

*** original *def initialize_query()

*

*end *private :initialize_query *** /original

Returns:

  • (Boolean)


1321
1322
1323
# File 'lib/cgialt/core.rb', line 1321

def multipart?
  @multipart
end

#negotiateObject

return ENV



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

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

#path_infoObject

return ENV



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

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

#path_translatedObject

return ENV



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

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

#pragmaObject

return ENV



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

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

#query_stringObject

return ENV



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

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

Get the raw cookies as a string.



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

def raw_cookie
  return env_table['HTTP_COOKIE']
end

#raw_cookie2Object

Get the raw RFC2965 cookies as a string.



967
968
969
# File 'lib/cgialt/core.rb', line 967

def raw_cookie2
  return env_table['HTTP_COOKIE2']
end

#refererObject

return ENV



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

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

#remote_addrObject

return ENV



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

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

#remote_hostObject

return ENV



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

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

#remote_identObject

return ENV



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

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

#remote_userObject

return ENV



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

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

#request_methodObject

return ENV



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

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

#script_nameObject

return ENV



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

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

#server_nameObject

return ENV



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

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

#server_portObject

return Integer(ENV)



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

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

#server_protocolObject

return ENV



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

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

#server_softwareObject

return ENV



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

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

#unescape_filename?Boolean

:nodoc:

Returns:

  • (Boolean)


1099
1100
1101
1102
# File 'lib/cgialt/core.rb', line 1099

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

#user_agentObject

return ENV



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

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