Decodes a native protocol message body :param protocol_version: version to use decoding contents :param user_type_map: map[keyspace name] = map[type name] = custom type to instantiate when deserializing this type :param stream_id: native protocol stream id from the
(cls, protocol_version, user_type_map, stream_id, flags, opcode, body,
decompressor, result_metadata)
| 1155 | |
| 1156 | @classmethod |
| 1157 | def decode_message(cls, protocol_version, user_type_map, stream_id, flags, opcode, body, |
| 1158 | decompressor, result_metadata): |
| 1159 | """ |
| 1160 | Decodes a native protocol message body |
| 1161 | |
| 1162 | :param protocol_version: version to use decoding contents |
| 1163 | :param user_type_map: map[keyspace name] = map[type name] = custom type to instantiate when deserializing this type |
| 1164 | :param stream_id: native protocol stream id from the frame header |
| 1165 | :param flags: native protocol flags bitmap from the header |
| 1166 | :param opcode: native protocol opcode from the header |
| 1167 | :param body: frame body |
| 1168 | :param decompressor: optional decompression function to inflate the body |
| 1169 | :return: a message decoded from the body and frame attributes |
| 1170 | """ |
| 1171 | if (not ProtocolVersion.has_checksumming_support(protocol_version) and |
| 1172 | flags & COMPRESSED_FLAG): |
| 1173 | if decompressor is None: |
| 1174 | raise RuntimeError("No de-compressor available for compressed frame!") |
| 1175 | body = decompressor(body) |
| 1176 | flags ^= COMPRESSED_FLAG |
| 1177 | |
| 1178 | body = io.BytesIO(body) |
| 1179 | if flags & TRACING_FLAG: |
| 1180 | trace_id = UUID(bytes=body.read(16)) |
| 1181 | flags ^= TRACING_FLAG |
| 1182 | else: |
| 1183 | trace_id = None |
| 1184 | |
| 1185 | if flags & WARNING_FLAG: |
| 1186 | warnings = read_stringlist(body) |
| 1187 | flags ^= WARNING_FLAG |
| 1188 | else: |
| 1189 | warnings = None |
| 1190 | |
| 1191 | if flags & CUSTOM_PAYLOAD_FLAG: |
| 1192 | custom_payload = read_bytesmap(body) |
| 1193 | flags ^= CUSTOM_PAYLOAD_FLAG |
| 1194 | else: |
| 1195 | custom_payload = None |
| 1196 | |
| 1197 | flags &= USE_BETA_MASK # will only be set if we asserted it in connection estabishment |
| 1198 | |
| 1199 | if flags: |
| 1200 | log.warning("Unknown protocol flags set: %02x. May cause problems.", flags) |
| 1201 | |
| 1202 | msg_class = cls.message_types_by_opcode[opcode] |
| 1203 | msg = msg_class.recv_body(body, protocol_version, user_type_map, result_metadata, cls.column_encryption_policy) |
| 1204 | msg.stream_id = stream_id |
| 1205 | msg.trace_id = trace_id |
| 1206 | msg.custom_payload = custom_payload |
| 1207 | msg.warnings = warnings |
| 1208 | |
| 1209 | if msg.warnings: |
| 1210 | for w in msg.warnings: |
| 1211 | log.warning("Server warning: %s", w) |
| 1212 | |
| 1213 | return msg |
| 1214 |
nothing calls this directly
no test coverage detected