decompress example

// If the body was chunk encoded, then decode it.         if ( ! empty( $processed_response['body'] )
            && isset( $processed_headers['headers']['transfer-encoding'] )
            && 'chunked' === $processed_headers['headers']['transfer-encoding']
        ) {
            $processed_response['body'] = WP_Http::chunkTransferDecode( $processed_response['body'] );
        }

        if ( true === $parsed_args['decompress']
            && true === WP_Http_Encoding::should_decode( $processed_headers['headers'] )
        ) {
            $processed_response['body'] = WP_Http_Encoding::decompress( $processed_response['body'] );
        }

        if ( isset( $parsed_args['limit_response_size'] )
            && strlen( $processed_response['body'] ) > $parsed_args['limit_response_size']
        ) {
            $processed_response['body'] = substr( $processed_response['body'], 0, $parsed_args['limit_response_size'] );
        }

        $response['body'] = $processed_response['body'];

        return $response;
    }


        // Handle redirects.         $redirect_response = WP_Http::handle_redirects( $url$parsed_args$response );
        if ( false !== $redirect_response ) {
            return $redirect_response;
        }

        if ( true === $parsed_args['decompress']
            && true === WP_Http_Encoding::should_decode( $processed_headers['headers'] )
        ) {
            $body = WP_Http_Encoding::decompress( $body );
        }

        $response['body'] = $body;

        return $response;
    }

    /** * Grabs the headers of the cURL request. * * Each header is sent individually to this callback, and is appended to the `$header` property * for temporary storage. * * @since 3.2.0 * * @param resource $handle cURL handle. * @param string $headers cURL request headers. * @return int Length of the request headers. */
$value             = trim($value);
            preg_replace('#(\s+)#i', ' ', $value);
            $return->headers[$key] = $value;
        }

        if (isset($return->headers['transfer-encoding'])) {
            $return->body = self::decode_chunked($return->body);
            unset($return->headers['transfer-encoding']);
        }

        if (isset($return->headers['content-encoding'])) {
            $return->body = self::decompress($return->body);
        }

        //fsockopen and cURL compatibility         if (isset($return->headers['connection'])) {
            unset($return->headers['connection']);
        }

        $options['hooks']->dispatch('requests.before_redirect_check', [&$return$req_headers$req_data$options]);

        if ($return->is_redirect() && $options['follow_redirects'] === true) {
            if (isset($return->headers['location']) && $options['redirected'] < $options['redirects']) {
                
Home | Imprint | This part of the site doesn't use cookies.