Class: Pione::Util::CGIInfo
- Inherits:
-
Object
- Object
- Pione::Util::CGIInfo
- Defined in:
- lib/pione/util/cgi.rb
Overview
CGIInfo is a store of CGI meta-variables based on RFC3875.
Instance Attribute Summary collapse
-
#auth_type ⇒ Object
CGI meta-variable "AUTH_TYPE".
-
#body ⇒ Object
request body.
-
#content_length ⇒ Object
CGI meta-variable "CONTENT_LENGTH".
-
#content_type ⇒ Object
CGI meta-variable "CONTENT_TYPE".
-
#gateway_interface ⇒ Object
CGI meta-variable "GATEWAY_INTERFACE".
-
#http_header ⇒ Object
HTTP specific variable table.
-
#path_info ⇒ Object
CGI meta-variable "PATH_INFO".
-
#path_translated ⇒ Object
CGI meta-variable "PATH_TRANSLATED".
-
#query_string ⇒ Object
CGI meta-variable "QUERY_STRING".
-
#remote_addr ⇒ Object
CGI meta-variable "REMOTE_ADDR".
-
#remote_host ⇒ Object
CGI meta-variable "REMOTE_HOST".
-
#remote_ident ⇒ Object
CGI meta-variable "REMOTE_IDENT".
-
#remote_user ⇒ Object
CGI meta-variable "REMOTE_USER".
-
#request_method ⇒ Object
CGI meta-variable "REQUEST_METHOD".
-
#script_name ⇒ Object
CGI meta-variable "SCRIPT_NAME".
-
#server_name ⇒ Object
CGI meta-variable "SERVER_NAME".
-
#server_port ⇒ Object
CGI meta-variable "SERVER_PORT".
-
#server_protocol ⇒ Object
CGI meta-variable "SERVER_PROTOCOL".
-
#server_software ⇒ Object
CGI meta-variable "SERVER_SOFTWARE".
Instance Method Summary collapse
- #create_arguments ⇒ Object
-
#create_env ⇒ Hash
Create environment variables.
-
#initialize ⇒ CGIInfo
constructor
A new instance of CGIInfo.
Constructor Details
#initialize ⇒ CGIInfo
Returns a new instance of CGIInfo.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pione/util/cgi.rb', line 68 def initialize @auth_type = nil @content_length = nil @content_type = nil @gateway_interface = "CGI/1.1" @path_info = nil @path_translated = nil @query_string = nil @remote_addr = nil @remote_host = nil @remote_ident = nil @remote_user = nil @request_method = nil @script_name = nil @server_name = nil @server_port = nil @server_protocol = "HTTP/1.1" @server_software = "PIONE/%s" % Pione::VERSION @body = nil @http_header = Hash.new end |
Instance Attribute Details
#auth_type ⇒ Object
CGI meta-variable "AUTH_TYPE"
12 13 14 |
# File 'lib/pione/util/cgi.rb', line 12 def auth_type @auth_type end |
#body ⇒ Object
request body
66 67 68 |
# File 'lib/pione/util/cgi.rb', line 66 def body @body end |
#content_length ⇒ Object
CGI meta-variable "CONTENT_LENGTH"
15 16 17 |
# File 'lib/pione/util/cgi.rb', line 15 def content_length @content_length end |
#content_type ⇒ Object
CGI meta-variable "CONTENT_TYPE"
18 19 20 |
# File 'lib/pione/util/cgi.rb', line 18 def content_type @content_type end |
#gateway_interface ⇒ Object
CGI meta-variable "GATEWAY_INTERFACE"
21 22 23 |
# File 'lib/pione/util/cgi.rb', line 21 def gateway_interface @gateway_interface end |
#http_header ⇒ Object
HTTP specific variable table
63 64 65 |
# File 'lib/pione/util/cgi.rb', line 63 def http_header @http_header end |
#path_info ⇒ Object
CGI meta-variable "PATH_INFO"
24 25 26 |
# File 'lib/pione/util/cgi.rb', line 24 def path_info @path_info end |
#path_translated ⇒ Object
CGI meta-variable "PATH_TRANSLATED"
27 28 29 |
# File 'lib/pione/util/cgi.rb', line 27 def path_translated @path_translated end |
#query_string ⇒ Object
CGI meta-variable "QUERY_STRING"
30 31 32 |
# File 'lib/pione/util/cgi.rb', line 30 def query_string @query_string end |
#remote_addr ⇒ Object
CGI meta-variable "REMOTE_ADDR"
33 34 35 |
# File 'lib/pione/util/cgi.rb', line 33 def remote_addr @remote_addr end |
#remote_host ⇒ Object
CGI meta-variable "REMOTE_HOST"
36 37 38 |
# File 'lib/pione/util/cgi.rb', line 36 def remote_host @remote_host end |
#remote_ident ⇒ Object
CGI meta-variable "REMOTE_IDENT"
39 40 41 |
# File 'lib/pione/util/cgi.rb', line 39 def remote_ident @remote_ident end |
#remote_user ⇒ Object
CGI meta-variable "REMOTE_USER"
42 43 44 |
# File 'lib/pione/util/cgi.rb', line 42 def remote_user @remote_user end |
#request_method ⇒ Object
CGI meta-variable "REQUEST_METHOD"
45 46 47 |
# File 'lib/pione/util/cgi.rb', line 45 def request_method @request_method end |
#script_name ⇒ Object
CGI meta-variable "SCRIPT_NAME"
48 49 50 |
# File 'lib/pione/util/cgi.rb', line 48 def script_name @script_name end |
#server_name ⇒ Object
CGI meta-variable "SERVER_NAME"
51 52 53 |
# File 'lib/pione/util/cgi.rb', line 51 def server_name @server_name end |
#server_port ⇒ Object
CGI meta-variable "SERVER_PORT"
54 55 56 |
# File 'lib/pione/util/cgi.rb', line 54 def server_port @server_port end |
#server_protocol ⇒ Object
CGI meta-variable "SERVER_PROTOCOL"
57 58 59 |
# File 'lib/pione/util/cgi.rb', line 57 def server_protocol @server_protocol end |
#server_software ⇒ Object
CGI meta-variable "SERVER_SOFTWARE"
60 61 62 |
# File 'lib/pione/util/cgi.rb', line 60 def server_software @server_software end |
Instance Method Details
#create_arguments ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/pione/util/cgi.rb', line 123 def create_arguments unless @query_string.include?("=") return @query_string.split("+").map do |arg| begin CGIUtils.decode(arg) rescue raise CGIError.failed_to_decode(@query_string) end end end return [] end |
#create_env ⇒ Hash
Create environment variables.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pione/util/cgi.rb', line 93 def create_env env = Hash.new # store CGI meta-variables env["AUTH_TYPE"] = @auth_type if @auth_type env["CONTENT_LENGTH"] = @content_length if @content_length env["CONTENT_TYPE"] = @content_type if @content_type env["GATEWAY_INTERFACE"] = @gateway_interface env["PATH_INFO"] = @path_info env["PATH_TRANSLATED"] = @path_translated env["QUERY_STRING"] = @query_string env["REMOTE_ADDR"] = @remote_addr env["REMOTE_HOST"] = @remote_host env["REMOTE_IDENT"] = @remote_ident if @remote_ident env["REMOTE_USER"] = @remote_user if @remote_user env["REQUEST_METHOD"] = @request_method.to_s env["SCRIPT_NAME"] = @script_name env["SERVER_NAME"] = @server_name env["SERVER_PORT"] = @server_port env["SERVER_PROTOCOL"] = @server_protocol env["SERVER_SOFTWARE"] = @server_software # store HTTP specific variables @http_header.each do |key, val| env["HTTP_%s" % key] = val end return env end |