Class: FCGI::Record

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

Overview

redefine

Constant Summary collapse

HEADER_FORMAT =

uint8_t protocol_version; uint8_t record_type; uint16_t request_id; (big endian) uint16_t content_length; (big endian) uint8_t padding_length; uint8_t reserved;

'CCnnCC'
HEADER_LENGTH =
8
RECORD_CLASS =
{
  FCGI_GET_VALUES    => GetValuesRecord,

  FCGI_BEGIN_REQUEST => BeginRequestRecord,
  FCGI_ABORT_REQUEST => AbortRequestRecord,
  FCGI_PARAMS        => ParamsRecord,
  FCGI_STDIN         => StdinDataRecord,
  FCGI_DATA          => DataRecord,
  FCGI_STDOUT        => StdoutDataRecord,
  FCGI_END_REQUEST   => EndRequestRecord
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, reqid) ⇒ Record

Returns a new instance of Record.



318
319
320
321
# File 'lib/cgialt/fcgi/core.rb', line 318

def initialize(type, reqid)
  @type = type
  @request_id = reqid
end

Instance Attribute Details

#request_idObject (readonly)

Returns the value of attribute request_id.



328
329
330
# File 'lib/cgialt/fcgi/core.rb', line 328

def request_id
  @request_id
end

#typeObject (readonly)

Returns the value of attribute type.



327
328
329
# File 'lib/cgialt/fcgi/core.rb', line 327

def type
  @type
end

Class Method Details

.class_for(type) ⇒ Object



314
315
316
# File 'lib/cgialt/fcgi/core.rb', line 314

def self::class_for(type)
  RECORD_CLASS[type]
end

.parse_header(buf) ⇒ Object



310
311
312
# File 'lib/cgialt/fcgi/core.rb', line 310

def self::parse_header(buf)
  return *buf.unpack(HEADER_FORMAT)
end

Instance Method Details

#management_record?Boolean

Returns:

  • (Boolean)


330
331
332
# File 'lib/cgialt/fcgi/core.rb', line 330

def management_record?
  @request_id == FCGI_NULL_REQUEST_ID
end

#serializeObject



334
335
336
337
338
339
# File 'lib/cgialt/fcgi/core.rb', line 334

def serialize
  body = make_body()
  padlen = body.length % 8
  header = make_header(body.length, padlen)
  header + body + "\000" * padlen
end

#versionObject



323
324
325
# File 'lib/cgialt/fcgi/core.rb', line 323

def version
  ::FCGI::ProtocolVersion
end