Class: Hobix::WebApp::Request

Inherits:
Message
  • Object
show all
Defined in:
lib/hobix/webapp/message.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#body_object, #header_object

Instance Method Summary collapse

Methods inherited from Message

#freeze, #output_body, #output_header, #output_message

Constructor Details

#initialize(request_line = nil, header = {}, body = '') ⇒ Request

Returns a new instance of Request.



126
127
128
129
# File 'lib/hobix/webapp/message.rb', line 126

def initialize(request_line=nil, header={}, body='')
  @request_line = request_line
  super header, body
end

Instance Attribute Details

#action_uriObject (readonly)

Returns the value of attribute action_uri.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def action_uri
  @action_uri
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def content_type
  @content_type
end

#path_infoObject (readonly)

Returns the value of attribute path_info.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def path_info
  @path_info
end

#query_stringObject (readonly)

Returns the value of attribute query_string.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def query_string
  @query_string
end

#remote_addrObject (readonly)

Returns the value of attribute remote_addr.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def remote_addr
  @remote_addr
end

#request_methodObject (readonly)

Returns the value of attribute request_method.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def request_method
  @request_method
end

#request_uriObject (readonly)

Returns the value of attribute request_uri.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def request_uri
  @request_uri
end

#script_nameObject (readonly)

Returns the value of attribute script_name.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def script_name
  @script_name
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def server_name
  @server_name
end

#server_portObject (readonly)

Returns the value of attribute server_port.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def server_port
  @server_port
end

#server_protocolObject (readonly)

Returns the value of attribute server_protocol.



130
131
132
# File 'lib/hobix/webapp/message.rb', line 130

def server_protocol
  @server_protocol
end

Instance Method Details

#make_request_header_from_cgi_env(env) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/hobix/webapp/message.rb', line 137

def make_request_header_from_cgi_env(env)
  env.each {|k, v|
    next if /\AHTTP_/ !~ k
    k = Header.capitalize_field_name($')
    k.gsub!(/_/, '-')
    @header_object.add k, v
  }
  @request_method = env['REQUEST_METHOD']
  @server_name = ( env['SERVER_NAME'] || '' ).gsub( /\:\d+$/, '' )  # lighttpd affixes port!!
  @server_port = env['SERVER_PORT'].to_i
  @script_name = env['SCRIPT_NAME'] || ''
  @path_info = env['PATH_INFO'] || ''
  @query_string = QueryString.primitive_new_for_raw_query_string(env['QUERY_STRING'] || '')
  @server_protocol = env['SERVER_PROTOCOL'] || ''
  @remote_addr = env['REMOTE_ADDR'] || ''
  @content_type = env['CONTENT_TYPE'] || ''

  # non-standard:
  @request_uri = env['REQUEST_URI'] # Apache

  # hobix action uri
  @action_uri = ( env['PATH_INFO'] || env['REQUEST_URI'] ).
    gsub( /^(#{ Regexp::quote( File::dirname( @script_name ) ) })?\/*/, '' ).
    gsub( /\?.+$/, '' )
end