Skip to main content
Version: Next

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

import { ApifyClient } from 'apify-client';

const identityCompressor = {
contentEncoding: 'identity',

async compress(data) {
return data;
},
};

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

Index

Properties

Methods

Properties

readonlycontentEncoding

contentEncoding: string

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

Methods

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.

Page Options