function buildHeaderValue(header) {
    switch (header.type) {
        case 'binary':
            var binBytes = allocBuffer(3);
            binBytes.writeUInt8(HEADER_VALUE_TYPE.byteArray, 0);
            binBytes.writeUInt16BE(header.value.length, 1);
            return Buffer.concat([
                binBytes, header.value
            ], binBytes.length + header.value.length);
        case 'boolean':
            var boolByte = allocBuffer(1);
            boolByte[0] = header.value ? HEADER_VALUE_TYPE.boolTrue : HEADER_VALUE_TYPE.boolFalse;
            return boolByte;
        case 'byte':
            var singleByte = allocBuffer(2);
            singleByte[0] = HEADER_VALUE_TYPE.byte;
            singleByte[1] = header.value;
            return singleByte;
        case 'integer':
            var intBytes = allocBuffer(5);
            intBytes.writeUInt8(HEADER_VALUE_TYPE.integer, 0);
            intBytes.writeInt32BE(header.value, 1);
            return intBytes;
        case 'long':
            var longBytes = allocBuffer(1);
            longBytes[0] = HEADER_VALUE_TYPE.long;
            return Buffer.concat([
                longBytes, header.value.bytes
            ], 9);
        case 'short':
            var shortBytes = allocBuffer(3);
            shortBytes.writeUInt8(HEADER_VALUE_TYPE.short, 0);
            shortBytes.writeInt16BE(header.value, 1);
            return shortBytes;
        case 'string':
            var utf8Bytes = toBuffer(header.value);
            var strBytes = allocBuffer(3);
            strBytes.writeUInt8(HEADER_VALUE_TYPE.string, 0);
            strBytes.writeUInt16BE(utf8Bytes.length, 1);
            return Buffer.concat([
                strBytes, utf8Bytes
            ], strBytes.length + utf8Bytes.length);
        case 'timestamp':
            var tsBytes = allocBuffer(1);
            tsBytes[0] = HEADER_VALUE_TYPE.timestamp;
            return Buffer.concat([
                tsBytes, Int64.fromNumber(header.value.valueOf()).bytes
            ], 9);
        case 'uuid':
            if (!UUID_PATTERN.test(header.value)) {
                throw new Error('Invalid UUID received: ' + header.value);
            }

            var uuidBytes = allocBuffer(1);
            uuidBytes[0] = HEADER_VALUE_TYPE.uuid;
            return Buffer.concat([
                uuidBytes, toBuffer(header.value.replace(/\-/g, ''), 'hex')
            ], 17);
    }
}
@param {object} header
@param {'boolean'|'byte'|'short'|'integer'|'long'|'binary'|'string'|'timestamp'|'uuid'} header.type
@param {*} header.value
@returns {Buffer}