src/compression.js

Method compression

Determines what/if compression is supported for a request

Parameters:

  • agent must be a String.
    (User-Agent header value)

  • encoding must be a String.
    (Accept-Encoding header value)

  • mimetype must be a String.
    (Mime type of response body)

Returns a Mixed
(Supported compression or null)

TurtleIO.prototype.compression = function ( agent, encoding, mimetype ) { var result = null, encodings = typeof encoding === "string" ? encoding.explode() : []; if ( REGEX_COMP.test( mimetype ) && this.config.compress === true && !REGEX_IE.test( agent ) ) {

Iterating supported encodings

encodings.each( function ( i ) { if ( REGEX_GZIP.test( i ) ) { result = "gz"; } else if ( REGEX_DEF.test( i ) ) { result = "zz"; }

Found a supported encoding

if ( result !== null ) { return false; } } ); } return result; };