MCPcopy Create free account
hub / github.com/tbphp/gpt-load / DecompressResponse

Function DecompressResponse

internal/utils/compression_utils.go:37–60  ·  view source on GitHub ↗

DecompressResponse automatically decompresses response data based on Content-Encoding header

(contentEncoding string, data []byte)

Source from the content-addressed store, hash-verified

35
36// DecompressResponse automatically decompresses response data based on Content-Encoding header
37func DecompressResponse(contentEncoding string, data []byte) ([]byte, error) {
38 // If no encoding specified or empty data, return as-is
39 if contentEncoding == "" || len(data) == 0 {
40 return data, nil
41 }
42
43 // Look up the decompressor
44 decompressor, exists := decompressorRegistry[contentEncoding]
45 if !exists {
46 logrus.Warnf("No decompressor registered for encoding '%s', returning original data", contentEncoding)
47 return data, nil
48 }
49
50 // Decompress
51 decompressed, err := decompressor.Decompress(data)
52 if err != nil {
53 logrus.WithError(err).Warnf("Failed to decompress with '%s', returning original data", contentEncoding)
54 return data, nil
55 }
56
57 logrus.Debugf("Successfully decompressed %d bytes -> %d bytes using '%s'",
58 len(data), len(decompressed), contentEncoding)
59 return decompressed, nil
60}
61
62// GzipDecompressor handles gzip compression
63type GzipDecompressor struct{}

Callers 1

Calls 1

DecompressMethod · 0.65

Tested by

no test coverage detected