Sha256: 98a5ddb1269d80dff8e5c354d84ee012115984a6c198f45373830f340b2120bd
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'm2r/request' module M2R # Mongrel2 Request Parser # @api public class Parser # 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 # @threadsafe true def parse(msg) sender, conn_id, path, rest = msg.split(' ', 4) headers, rest = TNetstring.parse(rest) body, _ = TNetstring.parse(rest) headers = MultiJson.load(headers) headers, mong = split_headers(headers) headers = Headers.new headers, true mong = Headers.new mong, true Request.new(sender, conn_id, path, headers, mong, body) end private def split_headers(headers) http = {} mongrel = {} headers.each do |header, value| if Request::MONGREL2_HEADERS.include?(header) mongrel[header.downcase] = value else http[header] = value end end return http, mongrel end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
m2r-2.1.0 | lib/m2r/parser.rb |
m2r-2.1.0.pre | lib/m2r/parser.rb |