Class: Web2Go::CGIRequest
- Inherits:
-
Object
- Object
- Web2Go::CGIRequest
- Defined in:
- lib/Web2Go/CGIRequest.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#server_variable ⇒ Object
readonly
Returns the value of attribute server_variable.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean (also: #authenticated)
- #cookie(name) ⇒ Object
- #cookies ⇒ Object
- #host ⇒ Object
-
#initialize(cgi) ⇒ CGIRequest
constructor
A new instance of CGIRequest.
- #parameter(name, default_value = nil) ⇒ Object
- #path ⇒ Object
- #port ⇒ Object
- #query_string ⇒ Object
- #request_method ⇒ Object
- #script_name ⇒ Object
- #uploaded_file(name, pos = 0) ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(cgi) ⇒ CGIRequest
Returns a new instance of CGIRequest.
29 30 31 32 33 34 |
# File 'lib/Web2Go/CGIRequest.rb', line 29 def initialize(cgi) @cgi = cgi @server_variable = cgi.my_env @params = @cgi.params @user = nil end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
26 27 28 |
# File 'lib/Web2Go/CGIRequest.rb', line 26 def params @params end |
#server_variable ⇒ Object (readonly)
Returns the value of attribute server_variable.
27 28 29 |
# File 'lib/Web2Go/CGIRequest.rb', line 27 def server_variable @server_variable end |
Instance Method Details
#authenticated? ⇒ Boolean Also known as: authenticated
78 79 80 |
# File 'lib/Web2Go/CGIRequest.rb', line 78 def authenticated? !@cgi.auth_type.nil? && !@cgi.auth_type.empty? end |
#cookie(name) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/Web2Go/CGIRequest.rb', line 105 def (name) if @cgi..has_key?(name) then return @cgi.[name] else return nil end end |
#cookies ⇒ Object
113 114 115 |
# File 'lib/Web2Go/CGIRequest.rb', line 113 def @cgi. end |
#host ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/Web2Go/CGIRequest.rb', line 44 def host if @server_variable.has_key?('HTTP_X_FORWARDED_HOST') then host = @server_variable['HTTP_X_FORWARDED_HOST'] else host = @cgi.server_name end if host =~ /^([^:]*):/ then host = $1 end host end |
#parameter(name, default_value = nil) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/Web2Go/CGIRequest.rb', line 88 def parameter(name,default_value=nil) value = @params[name] if value.nil? || value.length < 1 then return default_value else return value[0] end end |
#path ⇒ Object
40 41 42 |
# File 'lib/Web2Go/CGIRequest.rb', line 40 def path @cgi.path_info end |
#port ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/Web2Go/CGIRequest.rb', line 56 def port if @server_variable.has_key?('HTTP_X_FORWARDED_HOST') then host = @server_variable['HTTP_X_FORWARDED_HOST'] if host =~ /:(\d+)/ then $1 else '80' end else @cgi.server_port end end |
#query_string ⇒ Object
74 75 76 |
# File 'lib/Web2Go/CGIRequest.rb', line 74 def query_string @cgi.query_string end |
#request_method ⇒ Object
84 85 86 |
# File 'lib/Web2Go/CGIRequest.rb', line 84 def request_method @cgi.request_method end |
#script_name ⇒ Object
36 37 38 |
# File 'lib/Web2Go/CGIRequest.rb', line 36 def script_name @cgi.script_name end |
#uploaded_file(name, pos = 0) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/Web2Go/CGIRequest.rb', line 97 def uploaded_file(name,pos=0) file = @params[name] if !file.nil? then return CGIFile.new(file[pos]) end nil end |
#user ⇒ Object
69 70 71 72 |
# File 'lib/Web2Go/CGIRequest.rb', line 69 def user @user ||= find_user @user end |