Ruby CGI method
The following is a list of methods for the CGI class:
Serial number |
Method description |
---|---|
1 |
Html3: HTML3.2 Html4: HTML4.0 Strict Html4Tr: HTML4.0 Transitional Html4Fr: HTML4.0 Frameset |
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
CGI instantiation method
In the following example, we will CGI::new
is assigned to the c variable, and the list of methods is as follows:
Serial number |
Method description |
---|---|
1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
HTML generation method
You can use the corresponding HTML tag signature in the CGI instance to create the HTML tag, as shown below:
Example
#!/usr/bin/rubyrequire"cgi"cgi=CGI.new("html4")cgi.out{cgi.html{cgi.head{"\\n"+cgi.title{"This
Is a Test"} } +cgi.body{"\\n"+cgi.form{"\\n"+cgi.hr+cgi.h1{"A Form:"}
+"\\n"+cgi.textarea("get_text")+"\\n"+cgi.br+cgi.submit} } } }
CGI object Properties
You can use the following properties in the CGI instance:
Attribute |
Return value |
---|---|
Accept |
Acceptable MIME types |
accept_charset |
Acceptable character set |
accept_encoding |
Acceptable coding |
accept_language |
Acceptable language |
auth_type |
Acceptable type |
raw_cookie |
Cookie data (original string) |
content_length |
Content length |
content_type |
Content type |
From |
Client e-mail address |
gateway_interface |
CGI version |
path_info |
Path |
path_translated |
Converted path |
Query_string |
Query string |
referer |
Visit the web site before |
remote_addr |
Client host address (IP) |
remote_host |
Client hostname |
remote_ident |
Client name |
remote_user |
Authenticated user |
request_method |
Request method (GET, POST, etc.) |
script_name |
Parameter name |
server_name |
Server name |
server_port |
Server port |
server_protocol |
Server protocol |
server_software |
Server software |
user_agent |
User agent |