Tinkex.API.Compression (Tinkex v0.3.4)

View Source

Response compression handling for Tinkex API.

Handles gzip decompression and content-encoding header management.

Summary

Functions

Decompresses a Finch response if it's gzip-encoded.

Functions

decompress(response)

@spec decompress(Finch.Response.t()) :: Finch.Response.t()

Decompresses a Finch response if it's gzip-encoded.

Checks the content-encoding header and decompresses the body if it's gzip. Strips the content-encoding header after decompression.

Examples

iex> response = %Finch.Response{
...>   body: :zlib.gzip("test"),
...>   headers: [{"content-encoding", "gzip"}]
...> }
iex> decompressed = decompress(response)
iex> decompressed.body
"test"