Class: Web2Go::WebrickRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/Web2Go/WebrickRequest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ WebrickRequest

Returns a new instance of WebrickRequest.


26
27
28
29
30
31
32
# File 'lib/Web2Go/WebrickRequest.rb', line 26

def initialize(request)
    @request = request
    @server_variable = request.meta_vars
    @server_variable['SCRIPT_NAME'], @server_variable['PATH_INFO'] = split_script_and_path(clean(request.path))
    find_user(request)      
    @params = parse_parameters
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params


23
24
25
# File 'lib/Web2Go/WebrickRequest.rb', line 23

def params
  @params
end

#server_variableObject (readonly)

Returns the value of attribute server_variable


22
23
24
# File 'lib/Web2Go/WebrickRequest.rb', line 22

def server_variable
  @server_variable
end

#userObject (readonly)

Returns the value of attribute user


24
25
26
# File 'lib/Web2Go/WebrickRequest.rb', line 24

def user
  @user
end

Instance Method Details

#authenticated?Boolean Also known as: authenticated

Returns:

  • (Boolean)

50
51
52
# File 'lib/Web2Go/WebrickRequest.rb', line 50

def authenticated?
    @authenticated
end

74
75
76
# File 'lib/Web2Go/WebrickRequest.rb', line 74

def cookie(name)
    return @request.cookies.find { |cookie| cookie.name == name }
end

#cookiesObject


78
79
80
# File 'lib/Web2Go/WebrickRequest.rb', line 78

def cookies
    @request.cookies
end

#hostObject


42
43
44
# File 'lib/Web2Go/WebrickRequest.rb', line 42

def host
    @request.host
end

#parameter(name, default_value = nil) ⇒ Object


56
57
58
59
60
61
62
63
# File 'lib/Web2Go/WebrickRequest.rb', line 56

def parameter(name,default_value=nil)
    value = @params[name]
    if value.nil? then
        return default_value
    else
        return value[0]
    end
end

#pathObject


38
39
40
# File 'lib/Web2Go/WebrickRequest.rb', line 38

def path
    @server_variable['PATH_INFO']
end

#portObject


46
47
48
# File 'lib/Web2Go/WebrickRequest.rb', line 46

def port
    @request.port
end

#request_methodObject


82
83
84
# File 'lib/Web2Go/WebrickRequest.rb', line 82

def request_method
    @request.request_method
end

#script_nameObject


34
35
36
# File 'lib/Web2Go/WebrickRequest.rb', line 34

def script_name
    @server_variable['SCRIPT_NAME']
end

#uploaded_file(name, pos = 0) ⇒ Object


65
66
67
68
69
70
71
# File 'lib/Web2Go/WebrickRequest.rb', line 65

def uploaded_file(name,pos=0)
    file = @request.query[name]
    if !file.nil? then
        return WebrickFile.new(file)
    end
    nil
end