Class: Pione::Util::CGIInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pione/util/cgi.rb

Overview

CGIInfo is a store of CGI meta-variables based on RFC3875.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCGIInfo

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_typeObject

CGI meta-variable "AUTH_TYPE"



12
13
14
# File 'lib/pione/util/cgi.rb', line 12

def auth_type
  @auth_type
end

#bodyObject

request body



66
67
68
# File 'lib/pione/util/cgi.rb', line 66

def body
  @body
end

#content_lengthObject

CGI meta-variable "CONTENT_LENGTH"



15
16
17
# File 'lib/pione/util/cgi.rb', line 15

def content_length
  @content_length
end

#content_typeObject

CGI meta-variable "CONTENT_TYPE"



18
19
20
# File 'lib/pione/util/cgi.rb', line 18

def content_type
  @content_type
end

#gateway_interfaceObject

CGI meta-variable "GATEWAY_INTERFACE"



21
22
23
# File 'lib/pione/util/cgi.rb', line 21

def gateway_interface
  @gateway_interface
end

#http_headerObject

HTTP specific variable table



63
64
65
# File 'lib/pione/util/cgi.rb', line 63

def http_header
  @http_header
end

#path_infoObject

CGI meta-variable "PATH_INFO"



24
25
26
# File 'lib/pione/util/cgi.rb', line 24

def path_info
  @path_info
end

#path_translatedObject

CGI meta-variable "PATH_TRANSLATED"



27
28
29
# File 'lib/pione/util/cgi.rb', line 27

def path_translated
  @path_translated
end

#query_stringObject

CGI meta-variable "QUERY_STRING"



30
31
32
# File 'lib/pione/util/cgi.rb', line 30

def query_string
  @query_string
end

#remote_addrObject

CGI meta-variable "REMOTE_ADDR"



33
34
35
# File 'lib/pione/util/cgi.rb', line 33

def remote_addr
  @remote_addr
end

#remote_hostObject

CGI meta-variable "REMOTE_HOST"



36
37
38
# File 'lib/pione/util/cgi.rb', line 36

def remote_host
  @remote_host
end

#remote_identObject

CGI meta-variable "REMOTE_IDENT"



39
40
41
# File 'lib/pione/util/cgi.rb', line 39

def remote_ident
  @remote_ident
end

#remote_userObject

CGI meta-variable "REMOTE_USER"



42
43
44
# File 'lib/pione/util/cgi.rb', line 42

def remote_user
  @remote_user
end

#request_methodObject

CGI meta-variable "REQUEST_METHOD"



45
46
47
# File 'lib/pione/util/cgi.rb', line 45

def request_method
  @request_method
end

#script_nameObject

CGI meta-variable "SCRIPT_NAME"



48
49
50
# File 'lib/pione/util/cgi.rb', line 48

def script_name
  @script_name
end

#server_nameObject

CGI meta-variable "SERVER_NAME"



51
52
53
# File 'lib/pione/util/cgi.rb', line 51

def server_name
  @server_name
end

#server_portObject

CGI meta-variable "SERVER_PORT"



54
55
56
# File 'lib/pione/util/cgi.rb', line 54

def server_port
  @server_port
end

#server_protocolObject

CGI meta-variable "SERVER_PROTOCOL"



57
58
59
# File 'lib/pione/util/cgi.rb', line 57

def server_protocol
  @server_protocol
end

#server_softwareObject

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_argumentsObject



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_envHash

Create environment variables.

Returns:

  • (Hash)

    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