Liking cljdoc? Tell your friends :D

hyper.brotli

Brotli compression for HTTP responses and SSE streams.

Provides both one-shot compression (for page responses, via middleware) and streaming compression (for SSE connections where the LZ77 window is maintained across chunks for better ratios).

Brotli compression for HTTP responses and SSE streams.

Provides both one-shot compression (for page responses, via middleware)
and streaming compression (for SSE connections where the LZ77 window is
maintained across chunks for better ratios).
raw docstring

accepts-br?clj

(accepts-br? req)

Check if the request's Accept-Encoding header includes brotli.

Check if the request's Accept-Encoding header includes brotli.
sourceraw docstring

byte-array-out-streamclj

(byte-array-out-stream)

Create a ByteArrayOutputStream for use with compress-out-stream.

Create a ByteArrayOutputStream for use with compress-out-stream.
sourceraw docstring

close-streamclj

(close-stream br)

Close the brotli output stream. Safe to call on nil.

Close the brotli output stream. Safe to call on nil.
sourceraw docstring

compressclj

(compress data & {:as opts})

One-shot compress a string or byte array. Returns a byte array. Suitable for full page responses where max compression is preferred.

One-shot compress a string or byte array. Returns a byte array.
Suitable for full page responses where max compression is preferred.
sourceraw docstring

compress-out-streamclj

(compress-out-stream out-stream & {:as opts})

Create a BrotliOutputStream wrapping a ByteArrayOutputStream. Used for streaming compression where the LZ77 window is maintained across multiple chunks (e.g. SSE events).

Create a BrotliOutputStream wrapping a ByteArrayOutputStream.
Used for streaming compression where the LZ77 window is maintained
across multiple chunks (e.g. SSE events).
sourceraw docstring

compress-streamclj

(compress-stream out br chunk)

Write a string chunk into a streaming brotli compressor, flush, and return the compressed bytes. Resets the underlying ByteArrayOutputStream so the next call only returns newly compressed data.

The BrotliOutputStream maintains its LZ77 window across calls, giving better compression ratios for repeated SSE fragments.

Write a string chunk into a streaming brotli compressor, flush, and
return the compressed bytes. Resets the underlying ByteArrayOutputStream
so the next call only returns newly compressed data.

The BrotliOutputStream maintains its LZ77 window across calls, giving
better compression ratios for repeated SSE fragments.
sourceraw docstring

decompressclj

(decompress data)

Decompress a complete brotli-compressed byte array back to a UTF-8 string.

Decompress a complete brotli-compressed byte array back to a UTF-8 string.
sourceraw docstring

decompress-streamclj

(decompress-stream data)

Decompress brotli data that may be an incomplete stream (e.g. flushed streaming chunks that lack a final block).

Decompress brotli data that may be an incomplete stream (e.g. flushed
streaming chunks that lack a final block).
sourceraw docstring

encoder-paramsclj

(encoder-params {:keys [quality window-size]})

Build encoder parameters. quality: 0-11 (default 5 for streaming, 11 for static) window-size: 0 or 10-24 (default 24)

Build encoder parameters.
quality: 0-11 (default 5 for streaming, 11 for static)
window-size: 0 or 10-24 (default 24)
sourceraw docstring

ensure-brclj

source

wrap-brotliclj

(wrap-brotli handler)

Ring middleware that compresses response bodies with brotli. Only compresses when:

  • Client sends Accept-Encoding: br
  • Response body is a string (typical for HTML/JSON)
  • Response is not already encoded

Uses quality 11 (max) for one-shot responses since they're not latency-sensitive like streaming SSE.

Ring middleware that compresses response bodies with brotli.
Only compresses when:
- Client sends Accept-Encoding: br
- Response body is a string (typical for HTML/JSON)
- Response is not already encoded

Uses quality 11 (max) for one-shot responses since they're not
latency-sensitive like streaming SSE.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close