Class: FCGI::ValuesRecord

Inherits:
Record
  • Object
show all
Defined in:
lib/cgialt/fcgi/core.rb

Direct Known Subclasses

GetValuesRecord, ParamsRecord

Constant Summary

Constants inherited from Record

Record::HEADER_FORMAT, Record::HEADER_LENGTH, Record::RECORD_CLASS

Instance Attribute Summary collapse

Attributes inherited from Record

#request_id, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

class_for, #management_record?, parse_header, #serialize, #version

Constructor Details

#initialize(type, id, values) ⇒ ValuesRecord

Returns a new instance of ValuesRecord.



461
462
463
464
# File 'lib/cgialt/fcgi/core.rb', line 461

def initialize(type, id, values)
  super type, id
  @values = values
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



466
467
468
# File 'lib/cgialt/fcgi/core.rb', line 466

def values
  @values
end

Class Method Details

.parse(id, body) ⇒ Object



435
436
437
# File 'lib/cgialt/fcgi/core.rb', line 435

def self::parse(id, body)
  new(id, parse_values(body))
end

.parse_values(buf) ⇒ Object



439
440
441
442
443
444
445
446
# File 'lib/cgialt/fcgi/core.rb', line 439

def self::parse_values(buf)
  result = {}
  until buf.empty?
    name, value = *read_pair(buf)
    result[name] = value
  end
  result
end

.read_length(buf) ⇒ Object



454
455
456
457
458
459
# File 'lib/cgialt/fcgi/core.rb', line 454

def self::read_length(buf)
  if buf[0] >> 7 == 0
  then buf.slice!(0,1)[0]
  else buf.slice!(0,4).unpack('N')[0] & ((1<<31) - 1)
  end
end

.read_pair(buf) ⇒ Object



448
449
450
451
452
# File 'lib/cgialt/fcgi/core.rb', line 448

def self::read_pair(buf)
  nlen = read_length(buf)
  vlen = read_length(buf)
  return buf.slice!(0, nlen), buf.slice!(0, vlen)
end