new(options = {})
public
Create a new CGI instance.
tag_maker |
This is the same as using the options_hash form with the value
{ :tag_maker => tag_maker } Note that it is recommended to use
the options_hash form, since it also allows you specify the
charset you will accept.
|
options_hash |
A Hash that recognizes two options:
:accept_charset |
specifies encoding of received query string. If omitted, @@accept_charset is used. If
the encoding is not valid, a CGI::InvalidEncoding will be raised.
Example. Suppose @@accept_charset is
“UTF-8”
when not specified:
cgi=CGI.new
when specified as “EUC-JP”:
cgi=CGI.new(:accept_charset => "EUC-JP")
| :tag_maker |
String that specifies which version of the HTML generation methods to use. If
not specified, no HTML generation
methods will be loaded.
The following values are supported:
“html3” |
HTML 3.x
| “html4” |
HTML 4.0
| “html4Tr” |
HTML 4.0 Transitional
| “html4Fr” |
HTML 4.0 with Framesets
|
|
|
block |
If provided, the block is called when an invalid encoding is encountered.
For example:
encoding_errors={}
cgi=CGI.new(:accept_charset=>"EUC-JP") do |name,value|
encoding_errors[name] = value
end
|
Finally, if the CGI object is not created in a
standard CGI call environment (that is, it can’t
locate REQUEST_METHOD in its environment), then it will run in
“offline” mode. In this mode, it reads its parameters from the command
line or (failing that) from standard input. Otherwise, cookies and other
parameters are parsed automatically from the standard CGI locations, which varies according to the
REQUEST_METHOD.
Show source
def initialize(options = {}, &block)
@accept_charset_error_block=block if block_given?
@options={:accept_charset=>@@accept_charset}
case options
when Hash
@options.merge!(options)
when String
@options[:tag_maker]=options
end
@accept_charset=@options[:accept_charset]
if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE")
Apache.request.setup_cgi_env
end
extend QueryExtension
@multipart = false
initialize_query()
@output_cookies = nil
@output_hidden = nil
case @options[:tag_maker]
when "html3"
require 'cgi/html'
extend Html3
element_init()
extend HtmlExtension
when "html4"
require 'cgi/html'
extend Html4
element_init()
extend HtmlExtension
when "html4Tr"
require 'cgi/html'
extend Html4Tr
element_init()
extend HtmlExtension
when "html4Fr"
require 'cgi/html'
extend Html4Tr
element_init()
extend Html4Fr
element_init()
extend HtmlExtension
end
end