Class: PostgresPR::StartupMessage

### Home Classes Methods

### In Files

- lib/postgres-pr/message.rb

### Parent

PostgresPR::Message

### Methods

- #dump
- #parse

### Class/Module Index

Quicksearch

- PostgresPR
- PostgresPR::Authentification
- PostgresPR::AuthentificationClearTextPassword
- PostgresPR::AuthentificationCryptPassword
- PostgresPR::AuthentificationKerberosV4
- PostgresPR::AuthentificationKerberosV5
- PostgresPR::AuthentificationMD5Password
- PostgresPR::AuthentificationOk
- PostgresPR::AuthentificationSCMCredential
- PostgresPR::BackendKeyData
- PostgresPR::CommandComplete
- PostgresPR::Connection
- PostgresPR::Connection::Result
- PostgresPR::CopyInResponse
- PostgresPR::CopyOutResponse
- PostgresPR::DataRow
- PostgresPR::DumpError
- PostgresPR::EmptyQueryResponse
- PostgresPR::ErrorResponse
- PostgresPR::Message
- PostgresPR::NoticeErrorMixin
- PostgresPR::NoticeResponse
- PostgresPR::ParameterStatus
- PostgresPR::Parse
- PostgresPR::ParseComplete
- PostgresPR::ParseError
- PostgresPR::PasswordMessage
- PostgresPR::Query
- PostgresPR::ReadyForQuery
- PostgresPR::RowDescription
- PostgresPR::RowDescription::FieldInfo
- PostgresPR::SSLRequest
- PostgresPR::SaltedAuthentificationMixin
- PostgresPR::StartupMessage
- PostgresPR::Terminate
- PostgresPR::UnknownAuthType
- PostgresPR::UnknownMessageType
- Buffer
- Buffer::EOF
- Buffer::Error
- Postgres
- Postgres::Conversion
- Postgres::Conversion::ConversionError
- BinaryReaderMixin
- BinaryWriterMixin
- ByteOrder
- DatabaseError
- Error
- IO
- PGError
- PGconn
- PGresult
- TC_Conversion

No matching classes.

# PostgresPR::StartupMessage

### Public Instance Methods

dump() click to toggle source

    # File lib/postgres-pr/message.rb, line 478
    def dump
      sz = @params.inject(4 + 4) {|sum, kv| sum + kv[0].size + 1 + kv[1].size + 1} + 1

      buffer = Buffer.of_size(sz)
      buffer.write_int32_network(sz)
      buffer.write_int32_network(@proto_version)
      @params.each_pair {|key, value|
        buffer.write_cstring(key)
        buffer.write_cstring(value)
      }
      buffer.write_byte(0)

      raise DumpError unless buffer.at_end?
      return buffer.content
    end

parse(buffer) click to toggle source

    # File lib/postgres-pr/message.rb, line 494
    def parse(buffer)
      buffer.position = 4

      @proto_version = buffer.read_int32_network
      @params = {}

      while buffer.position < buffer.size-1
        key = buffer.read_cstring
        val = buffer.read_cstring
        @params[key] = val
      end

      nul = buffer.read_byte
      raise ParseError unless nul == 0
      raise ParseError unless buffer.at_end?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.