CKRequest

Class/Module:
Class
In:
lib/cgikit.rb
Parent:
CKMessage

Description

CKRequest represents requests of HTTP headers.

CKRequest returns form parameters and cookies. But, in many cases, this class isn’t used directly to get parameters because CGIKit sets these parameters to components automatically in the process of instanciating components.

Getting a request object

You can get a request object by CKApplication#request or CKComponent#request.

Parameters

CKRequest has some methods to access parameters.

form_values[key]:Returns an array of parameters. If key is missing, returns an empty array.
form_value(key), [key]:This method returns a first object of an array of parameters. If key is missing, returns nil.

Cookies

Cookies is an array which includes some CKCookie objects. See CKCookie section about details of cookie.

cookie(key):Returns a CKCookie object whose key is the same as the argument.
cookies:Returns an array of CKCookie objects.
cookie_value(key):Returns the value of CKCookie object whose key is the the same as the argument.
cookie_values(key):If the argument is nil (by default, argument is nil.), this method returns an array which has all the values of cookies. Otherwise, it returns an array which has the values of cookies specified by the argument.

HTTP Headers

Some of HTTP headers are defined by instance methods. Call CKRequest#headers to get other CGI environment variables.

headers[key]:Returns a value of HTTP header.
accept:HTTP_ACCEPT
accept_charset:HTTP_ACCEPT_CHARSET
accept_language:HTTP_ACCEPT_LANGUAGE
auth_type:AUTH_TYPE
content_length:CONTENT_LENGTH
content_type:CONTENT_TYPE
from:HTTP_FROM
gateway_interface:GATEWAY_INTERFACE
path_info:PATH_INFO
path_translated:PATH_TRANSLATED
query_string:QUERY_STRING
raw_cookie:HTTP_COOKIE
referer:HTTP_REFERER
remote_addr:REMOTE_ADDR
remote_host:HTTP_HOST
remote_ident:REMOTE_IDENT
remote_user:REMOTE_USER
request_method:REQUEST_METHOD
script_name:SCRIPT_NAME
server_name:SERVER_NAME
server_port:SERVER_PORT
server_protocol:SERVER_PROTOCOL
server_software:SERVER_SOFTWARE
uri, url:REQUEST_URI
user_agent:HTTP_USER_AGENT

Methods

[]
accept
accept_charset
accept_language
auth_type
content_length
content_type
cookie
cookie_value
cookie_values
form_value
from
gateway_interface
languages
new
parse_query_string
path_info
path_translated
query_string
raw_cookie
referer
remote_addr
remote_host
remote_ident
remote_user
request_method
script_name
server_name
server_port
server_protocol
server_software
uri
url
user_agent

Attributes

form_values [RW]
Array of parameters.

Public Class Methods

new( headers = nil, form_values = nil )
parse_query_string( query )

Parse query string and return a hash of parameters.

Public Instance Methods

[]( key )

Alias for form_value

accept()
accept_charset()
accept_language()
auth_type()
content_length()
content_type()
cookie( key )

Returns a CKCookie object whose key is the same as the argument.

cookie_value( key )

Returns the value of CKCookie object whose key is the the same as the argument.

cookie_values( key = nil )

If the argument is nil (by default, argument is nil.), this method returns an array which has all the values of cookies. Otherwise, it returns an array which has the values of cookies specified by the argument.

form_value( key )

Returns a first object of an array of parameters. If key is missing, returns nil.

from()
gateway_interface()
languages()

Returns an array of languages for localization. The order is the preferred order of languages.

path_info()
path_translated()
query_string()
raw_cookie()
referer()
remote_addr()
remote_host()
remote_ident()
remote_user()
request_method()
script_name()
server_name()
server_port()
server_protocol()
server_software()
uri()
url()

Alias for uri

user_agent()