class M2R::Request

Abstraction over Mongrel 2 request @api public

Constants

MONGREL2_BASE_HEADERS

@api private

MONGREL2_HEADERS

@api private

MONGREL2_UPLOAD_HEADERS

@api private

TRUE_STRINGS

@api private

Attributes

body[R]

@return [String] HTTP Body of request

conn_id[R]

@return [String] Mongrel2 connection id sending this request

path[R]

@return [String] HTTP Path of request

sender[R]

@return [String] UUID of mongrel2 origin instance

Public Class Methods

new(sender, conn_id, path, http_headers, mongrel_headers, body) click to toggle source

@param [String] sender UUID of mongrel2 origin instance @param [String] conn_id Mongrel2 connection id sending this request @param [String] path HTTP Path of request @param [M2R::Headers] headers HTTP headers of request @param [M2R::Headers] headers Additional mongrel2 headers @param [String] body HTTP Body of request

# 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
parse(msg) click to toggle source

Parse Mongrel2 request received via ZMQ message

@param [String] msg Monrel2 Request message formatted according to rules

of creating it described it m2 manual.

@return [Request]

@api public @deprecated

# File lib/m2r/request.rb, line 60
def self.parse(msg)
  Parser.new.parse(msg)
end

Public Instance Methods

disconnect?() click to toggle source

@return [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}
# File lib/m2r/request.rb, line 96
def disconnect?
  json? and @data['type'] == 'disconnect'
end
headers() click to toggle source

@return [M2R::Headers] HTTP headers

# File lib/m2r/request.rb, line 65
def headers
  @http_headers
end
http_version() click to toggle source
# File lib/m2r/request.rb, line 89
def http_version
  @mongrel_headers['version']
end
method() click to toggle source

@return [String] HTTP method

# File lib/m2r/request.rb, line 75
def method
  @mongrel_headers['method']
end
pattern() click to toggle source

@return [String] Mongrel2 pattern used to match this request

# File lib/m2r/request.rb, line 70
def pattern
  @mongrel_headers['pattern']
end
query() click to toggle source

@return [String] Request query string

# File lib/m2r/request.rb, line 80
def query
  @mongrel_headers['query']
end
scheme() click to toggle source

return [String] URL scheme

# File lib/m2r/request.rb, line 85
def scheme
  @mongrel_headers['url_scheme'] || mongrel17_scheme
end

Protected Instance Methods

env_https() click to toggle source
# File lib/m2r/request.rb, line 107
def env_https
  (ENV['HTTPS'] || "").downcase
end
json?() click to toggle source
# File lib/m2r/request.rb, line 111
def json?
  method == 'JSON'
end
mongrel17_scheme() click to toggle source
# File lib/m2r/request.rb, line 102
def mongrel17_scheme
  return 'https' if TRUE_STRINGS.include? env_https
  return 'http'
end