# HttpCompressor<!-- -->

Strategy for compressing HTTP request bodies.

Implement this interface to create a custom compressor. Set `contentEncoding` to the value that should be sent in the `Content-Encoding` header and implement `compress()`. The client calls it only for bodies that are large enough to benefit from compression, whose content type does not already carry its own compression, and which the caller did not send with a `Content-Encoding` of their own.

### Implemented by

* [BrotliHttpCompressor](https://docs.apify.com/api/client/js/reference/class/BrotliHttpCompressor.md)
* [GzipHttpCompressor](https://docs.apify.com/api/client/js/reference/class/GzipHttpCompressor.md)
* [ZstdHttpCompressor](https://docs.apify.com/api/client/js/reference/class/ZstdHttpCompressor.md)

```
import { ApifyClient } from 'apify-client';



const identityCompressor = {

    contentEncoding: 'identity',



    async compress(data) {

        return data;

    },

};



const client = new ApifyClient({ token: 'my-token', compression: identityCompressor });
```

## Index[](#Index)

### Properties

* [contentEncoding](#contentEncoding)

### Methods

* [compress](#compress)

## Properties<!-- -->[](#Properties)

### [](#contentEncoding)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/http_compressors/base.ts#L28)readonlycontentEncoding

contentEncoding: string

Value sent in the `Content-Encoding` header, for example `gzip` or `br`.

## Methods<!-- -->[](#Methods)

### [](#compress)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/http_compressors/base.ts#L36)compress

* **compress**(data): Promise\<Buffer\<ArrayBufferLike>>

- Compresses a request body.

  ***

  #### Parameters

  * ##### data: Buffer\<ArrayBufferLike>

    The raw bytes to compress.

  #### Returns Promise\<Buffer\<ArrayBufferLike>>

  The compressed bytes.
