Pristine.Adapters.Compression.Gzip (Pristine v0.3.0)

Copy Markdown View Source

Gzip compression adapter using Erlang's :zlib module.

Provides gzip compression and decompression for request/response bodies.

Summary

Functions

Compresses binary data using gzip.

Returns the content encoding identifier for gzip.

Decompresses gzip-encoded binary data.

Functions

compress(data, opts \\ [])

Compresses binary data using gzip.

Options

  • :level - Compression level (currently ignored, uses default)

Examples

iex> {:ok, compressed} = Pristine.Adapters.Compression.Gzip.compress("hello")
iex> is_binary(compressed)
true

content_encoding()

Returns the content encoding identifier for gzip.

Examples

iex> Pristine.Adapters.Compression.Gzip.content_encoding()
"gzip"

decompress(data, opts \\ [])

Decompresses gzip-encoded binary data.

Options

Currently no options are supported.

Examples

iex> compressed = :zlib.gzip("hello")
iex> Pristine.Adapters.Compression.Gzip.decompress(compressed)
{:ok, "hello"}

iex> Pristine.Adapters.Compression.Gzip.decompress("invalid")
{:error, :invalid_gzip_data}