Compression Module
Types
| Type | Description |
Functions and values
| Function or value | Description |
Full Usage:
MAX_BYTES_TO_COMPRESS
Returns: int
|
|
Full Usage:
MIN_BYTES_TO_COMPRESS
Returns: int
|
|
|
|
|
|
Full Usage:
getEncoder request
Parameters:
HttpRequest
Returns: (Algorithm * (byte[] -> byte[])) option
|
|
|
|
|
|
Full Usage:
transform content ctx
Parameters:
byte[]
ctx : HttpContext
Returns: Task<Algorithm option * byte[]>
|
|
|
|
Full Usage:
transformSync content ctx
Parameters:
byte[]
ctx : HttpContext
Returns: Algorithm option * byte[]
|
Synchronous compression decision + transform.
Hot-path-aware:
1. If `content.Length` is outside the compressible range, returns immediately
with no allocation and without inspecting any request headers.
2. Otherwise checks for `accept-encoding`; if absent or unmatched, returns
`(None, content)` without allocating a Task.
3. Only when we are actually going to compress do we allocate the encoded
byte array.
This replaces the previous `task { }`-wrapped version that paid for a state
machine + Task box + header lookup + comma-split + Array.map/tryPick on
every `Bytes` response, even when no compression was possible.
|