Class: M2R::Request
- Inherits:
-
Object
- Object
- M2R::Request
- Includes:
- Base, HTTP::Close, Upload
- Defined in:
- lib/m2r/request.rb
Overview
Abstraction over Mongrel 2 request
Constant Summary collapse
- TRUE_STRINGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new(%w(true yes on 1).map(&:freeze)).freeze
- MONGREL2_BASE_HEADERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new(%w(pattern method path query url_scheme version).map(&:upcase).map(&:freeze)).freeze
- MONGREL2_UPLOAD_HEADERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new(%w(x-mongrel2-upload-start x-mongrel2-upload-done).map(&:downcase).map(&:freeze)).freeze
- MONGREL2_HEADERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
(MONGREL2_BASE_HEADERS + MONGREL2_UPLOAD_HEADERS).freeze
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
HTTP Body of request.
-
#conn_id ⇒ String
readonly
Mongrel2 connection id sending this request.
-
#path ⇒ String
readonly
HTTP Path of request.
-
#sender ⇒ String
readonly
UUID of mongrel2 origin instance.
Class Method Summary collapse
- .parse(msg) ⇒ Request deprecated Deprecated.
Instance Method Summary collapse
-
#disconnect? ⇒ true, false
Internal mongrel2 message to handler issued when message delivery is not possible because the client already disconnected and there is no connection with such #conn_id.
-
#headers ⇒ M2R::Headers
HTTP headers.
- #http_version ⇒ Object
-
#initialize(sender, conn_id, path, http_headers, mongrel_headers, body) ⇒ Request
constructor
A new instance of Request.
-
#method ⇒ String
HTTP method.
-
#pattern ⇒ String
Mongrel2 pattern used to match this request.
-
#query ⇒ String
Request query string.
-
#scheme ⇒ Object
return [String] URL scheme.
Methods included from HTTP::Close
Methods included from Upload
#body_io, #free!, #upload?, #upload_done?, #upload_path, #upload_start?
Methods included from Base
Constructor Details
#initialize(sender, conn_id, path, http_headers, mongrel_headers, body) ⇒ Request
Returns a new instance of Request.
42 43 44 45 46 47 48 49 50 |
# File 'lib/m2r/request.rb', line 42 def initialize(sender, conn_id, path, http_headers, mongrel_headers, body) @sender = sender @conn_id = conn_id @path = path @http_headers = http_headers @mongrel_headers = mongrel_headers @body = body @data = MultiJson.load(@body) if json? end |
Instance Attribute Details
#body ⇒ String (readonly)
Returns HTTP Body of request.
34 35 36 |
# File 'lib/m2r/request.rb', line 34 def body @body end |
#conn_id ⇒ String (readonly)
Returns Mongrel2 connection id sending this request.
28 29 30 |
# File 'lib/m2r/request.rb', line 28 def conn_id @conn_id end |
#path ⇒ String (readonly)
Returns HTTP Path of request.
31 32 33 |
# File 'lib/m2r/request.rb', line 31 def path @path end |
#sender ⇒ String (readonly)
Returns UUID of mongrel2 origin instance.
25 26 27 |
# File 'lib/m2r/request.rb', line 25 def sender @sender end |
Class Method Details
Instance Method Details
#disconnect? ⇒ true, false
Returns Internal mongrel2 message to handler issued when message delivery is not possible because the client already disconnected and there is no connection with such #conn_id.
96 97 98 |
# File 'lib/m2r/request.rb', line 96 def disconnect? json? and @data['type'] == 'disconnect' end |
#headers ⇒ M2R::Headers
Returns HTTP headers.
65 66 67 |
# File 'lib/m2r/request.rb', line 65 def headers @http_headers end |
#http_version ⇒ Object
89 90 91 |
# File 'lib/m2r/request.rb', line 89 def http_version @mongrel_headers['version'] end |
#method ⇒ String
Returns HTTP method.
75 76 77 |
# File 'lib/m2r/request.rb', line 75 def method @mongrel_headers['method'] end |
#pattern ⇒ String
Returns Mongrel2 pattern used to match this request.
70 71 72 |
# File 'lib/m2r/request.rb', line 70 def pattern @mongrel_headers['pattern'] end |
#query ⇒ String
Returns Request query string.
80 81 82 |
# File 'lib/m2r/request.rb', line 80 def query @mongrel_headers['query'] end |
#scheme ⇒ Object
return [String] URL scheme
85 86 87 |
# File 'lib/m2r/request.rb', line 85 def scheme @mongrel_headers['url_scheme'] || mongrel17_scheme end |