class FCGI::ValuesRecord
Attributes
Public Class Methods
Source
# File lib/fcgi.rb, line 477 def initialize(type, id, values) super type, id @values = values end
Calls superclass method
FCGI::Record::new
Source
# File lib/fcgi.rb, line 439 def self.parse(id, body) new(id, parse_values(body)) end
Source
# File lib/fcgi.rb, line 443 def self.parse_values(buf) result = {} until buf.empty? name, value = *read_pair(buf) result[name] = value end result end
Source
# File lib/fcgi.rb, line 460 def self.read_length(buf) if buf[0].bytes.first >> 7 == 0 buf.slice!(0,1)[0].bytes.first else buf.slice!(0,4).unpack('N')[0] & ((1<<31) - 1) end end
Source
# File lib/fcgi.rb, line 452 def self.read_pair(buf) nlen = read_length(buf) vlen = read_length(buf) [buf.slice!(0, nlen), buf.slice!(0, vlen)] end
Private Instance Methods
Source
# File lib/fcgi.rb, line 486 def make_body buf = '' @values.each do |name, value| buf << serialize_length(name.length) buf << serialize_length(value.length) buf << name buf << value end buf end
Source
# File lib/fcgi.rb, line 497 def serialize_length(len) if len < 0x80 then len.chr else [len | (1<<31)].pack('N') end end