class CGI
def initialize(options = {}, &block) # :yields: name, value
CGI locations, which varies according to the REQUEST_METHOD.
cookies and other parameters are parsed automatically from the standard
from the command line or (failing that) from standard input. Otherwise,
then it will run in "offline" mode. In this mode, it reads its parameters
environment (that is, it can't locate REQUEST_METHOD in its environment),
Finally, if the CGI object is not created in a standard CGI call
end
encoding_errors[name] = value
cgi=CGI.new(:accept_charset=>"EUC-JP") do |name,value|
encoding_errors={}
encountered. For example:
If provided, the block is called when an invalid encoding is
block::
cgi=CGI.new(:max_multipart_length => -> {check_filesystem}) # lambda
cgi=CGI.new(:max_multipart_length => 268435456) # simple scalar
Default is 128 * 1024 * 1024 bytes
multipart data (e.g. consult a registered users upload allowance)
allows more complex logic to be set when determining whether to accept
a lambda, that will be evaluated when the request is parsed. This
Specifies maximum length of multipart data. Can be an Integer scalar or
:max_multipart_length::
"html5":: HTML 5
"html4Fr":: HTML 4.0 with Framesets
"html4Tr":: HTML 4.0 Transitional
"html4":: HTML 4.0
"html3":: HTML 3.x
The following values are supported:
use. If not specified, no HTML generation methods will be loaded.
String that specifies which version of the HTML generation methods to
:tag_maker::
cgi=CGI.new(:accept_charset => "EUC-JP") # => "EUC-JP"
when specified as "EUC-JP":
cgi=CGI.new # @accept_charset # => "UTF-8"
when not specified:
Example. Suppose @@accept_charset is "UTF-8"
CGI::InvalidEncoding will be raised.
@@accept_charset is used. If the encoding is not valid, a
specifies encoding of received query string. If omitted,
:accept_charset::
A Hash that recognizes three options:
options_hash::
will accept.
+options_hash+ form, since it also allows you specify the charset you
:tag_maker => tag_maker } Note that it is recommended to use the
This is the same as using the +options_hash+ form with the value {
tag_maker::
CGI.new(options_hash = {}) { block }
CGI.new(tag_maker) { block }
:call-seq:
Create a new CGI instance.
def initialize(options = {}, &block) # :yields: name, value @accept_charset_error_block = block_given? ? block : nil @options={ :accept_charset=>@@accept_charset, :max_multipart_length=>@@max_multipart_length } case options when Hash @options.merge!(options) when String @options[:tag_maker]=options end @accept_charset=@options[:accept_charset] @max_multipart_length=@options[:max_multipart_length] if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE") Apache.request.setup_cgi_env end extend QueryExtension @multipart = false initialize_query() # set @params, @cookies @output_cookies = nil @output_hidden = nil case @options[:tag_maker] when "html3" require_relative 'html' extend Html3 extend HtmlExtension when "html4" require_relative 'html' extend Html4 extend HtmlExtension when "html4Tr" require_relative 'html' extend Html4Tr extend HtmlExtension when "html4Fr" require_relative 'html' extend Html4Tr extend Html4Fr extend HtmlExtension when "html5" require_relative 'html' extend Html5 extend HtmlExtension end end