Table of Contents

Class PacketCompressionUtils

Utility class providing GZip compression and decompression helpers for Packet payloads. Use these methods to reduce the wire size of large JSON payloads before sending.

public static class PacketCompressionUtils
Inheritance
PacketCompressionUtils
Inherited Members

Methods

CompressPayload(Packet)

GZip-compresses the Payload in-place and encodes it as Base64. Sets Header to "gzip" to signal the encoding.

public static void CompressPayload(Packet packet)

Parameters

packet Packet

The packet whose payload should be compressed.

Exceptions

ArgumentNullException

Thrown when packet is null.

CompressToBase64(string)

Compresses a plain-text string using GZip and returns it as a Base64 string.

public static string CompressToBase64(string text)

Parameters

text string

The text to compress.

Returns

string

A Base64-encoded GZip-compressed representation of text, or the original string if empty.

DecompressFromBase64(string)

Decompresses a Base64-encoded GZip string back to its original plain text.

public static string DecompressFromBase64(string base64)

Parameters

base64 string

The Base64-encoded GZip string to decompress.

Returns

string

The original plain-text string, or the input if empty.

DecompressPayload(Packet)

Decompresses a GZip Base64-encoded Payload back to its original string. Clears Header after decompression.

public static void DecompressPayload(Packet packet)

Parameters

packet Packet

The packet whose payload should be decompressed.

Exceptions

ArgumentNullException

Thrown when packet is null.