Skip to content

Commit 37e2bcb

Browse files
committed
fix: gzip compression compatibility for empty responses
1 parent ceb7bf4 commit 37e2bcb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/KurrentDB.Common/Compression/Rfc1952GzipCompressionProvider.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,20 @@ async ValueTask WriteEmptyGZipPayloadAsync(CancellationToken cancellationToken =
9292

9393
// See RFC 1952 (https://datatracker.ietf.org/doc/html/rfc1952)
9494
static ReadOnlyMemory<byte> EmptyGzip => new byte[] {
95+
// GZIP Header (RFC 1952)
9596
0x1f, 0x8b, // Magic number
9697
0x08, // Compression method: deflate
9798
0x00, // Flags: none
9899
0x00, 0x00, 0x00, 0x00, // Modification time: 0 (unknown)
99100
0x00, // Extra flags: none
100101
0xff, // Operating system: unknown (255)
101-
0x03, 0x00, // Block header: no compression, 0 bytes
102-
0x00, 0x00, // LEN = 0, NLEN = 0 (complement)
102+
103+
// DEFLATE Block (RFC 1951)
104+
0x01, // BFINAL=1, BTYPE=00 (stored/no compression)
105+
0x00, 0x00, // LEN = 0
106+
0xff, 0xff, // NLEN = 0xFFFF (one's complement of 0)
107+
108+
// GZIP Footer (RFC 1952)
103109
0x00, 0x00, 0x00, 0x00, // CRC-32 for empty data
104110
0x00, 0x00, 0x00, 0x00 // Size: 0 bytes
105111
};

0 commit comments

Comments
 (0)