Class: Waitress::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/waitress/request.rb

Overview

The request class is used to represent a HTTP request by a client. This includes all the headers sent to the server by the client, request URI and those properties parsed by Mongrel, including the Path and QueryString. GET and POST queries are to be parsed on-request by the handler or .wrb file as to not waste CPU resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, path, uri, query, http_version, body, headers) ⇒ Request

Returns a new instance of Request.



16
17
18
19
20
21
22
23
24
25
# File 'lib/waitress/request.rb', line 16

def initialize method, path, uri, query, http_version, body, headers
  @method = method
  @path = Waitress::QueryParser.unescape(path)
  @uri = Waitress::QueryParser.unescape(uri)
  @querystring = query
  @http_version = http_version
  @body = body
  @headers = headers
  @marks = {}
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



13
14
15
# File 'lib/waitress/request.rb', line 13

def body
  @body
end

#headersObject

Returns the value of attribute headers.



14
15
16
# File 'lib/waitress/request.rb', line 14

def headers
  @headers
end

#http_versionObject

Returns the value of attribute http_version.



12
13
14
# File 'lib/waitress/request.rb', line 12

def http_version
  @http_version
end

#methodObject

Returns the value of attribute method.



8
9
10
# File 'lib/waitress/request.rb', line 8

def method
  @method
end

#pathObject

Returns the value of attribute path.



9
10
11
# File 'lib/waitress/request.rb', line 9

def path
  @path
end

#querystringObject

Returns the value of attribute querystring.



11
12
13
# File 'lib/waitress/request.rb', line 11

def querystring
  @querystring
end

#uriObject

Returns the value of attribute uri.



10
11
12
# File 'lib/waitress/request.rb', line 10

def uri
  @uri
end

Instance Method Details

#get_queryObject

The GET query for the request in the form of a hash. This is parsed on-request



28
29
30
31
# File 'lib/waitress/request.rb', line 28

def get_query
  @get ||= Waitress::QueryParser.parse(@querystring)
  @get
end

#post_queryObject

The POST query for the request in the form of a hash. This is parsed on-request



34
35
36
37
# File 'lib/waitress/request.rb', line 34

def post_query
  @post ||= Waitress::QueryParser.parse(@body)
  @post
end

#to_sObject



39
40
41
42
# File 'lib/waitress/request.rb', line 39

def to_s
  m = lambda { |a,x| x.nil? ? "" : "#{a}=#{x.inspect}" }
  "#<#{self.class} method=#{@method} path=#{@path} #{m.call("query", @query)}>"
end