CNP compression (draft)

Overview

This draft aims to specify the protocol for compressing body data of CNP requests and responses.

Syntax

A new request and response parameter, compression, would be defined:

compression={algorithm}

Where {algorithm} is the compression algorithm used.

A request parameter, accept_compression, would be defined:

accept_compression={algorithms}

Where {algorithms} is a comma-separated list of compression algorithms (e.g. accept_compression=lz4,gzip,deflate) with decreasing priority.

Functionality

The body data of the message is compressed using the specified algorithm.

If the length parameter is to be set, it must contain the length of the data after compression, not before it.

The client should only use the standard compression algorithms or ones provided by the server in something like the options selector.

The server may use any compression algorithm provided in the accept_compression request parameter, with the ones towards the start of the list being preferred; if that parameter is absent, the server must not use compression.

Algorithms

While custom compression algorithms may be used, all server implementations are expected to support the following ones:

Possible changes

  • Remove all but gzip algorithms from the default ones, since they're all basically DEFLATE (plus maybe checksum).

  • Consider algorithms like Brotli.