Skip to content
Snippets Groups Projects
Select Git revision
  • 023dd3b74cf659fda61a9ad02c20d340253dad2c
  • master default
2 results

ai-auth-server.init

Blame
  • class-wp-http-encoding.php 6.39 KiB
    <?php
    /**
     * HTTP API: WP_Http_Encoding class
     *
     * @package WordPress
     * @subpackage HTTP
     * @since 4.4.0
     */
    
    /**
     * Core class used to implement deflate and gzip transfer encoding support for HTTP requests.
     *
     * Includes RFC 1950, RFC 1951, and RFC 1952.
     *
     * @since 2.8.0
     */
    class WP_Http_Encoding {
    
    	/**
    	 * Compress raw string using the deflate format.
    	 *
    	 * Supports the RFC 1951 standard.
    	 *
    	 * @since 2.8.0
    	 *
    	 * @param string $raw String to compress.
    	 * @param int $level Optional, default is 9. Compression level, 9 is highest.
    	 * @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports.
    	 * @return string|false False on failure.
    	 */
    	public static function compress( $raw, $level = 9, $supports = null ) {
    		return gzdeflate( $raw, $level );
    	}
    
    	/**
    	 * Decompression of deflated string.
    	 *
    	 * Will attempt to decompress using the RFC 1950 standard, and if that fails
    	 * then the RFC 1951 standard deflate will be attempted. Finally, the RFC
    	 * 1952 standard gzip decode will be attempted. If all fail, then the
    	 * original compressed string will be returned.
    	 *
    	 * @since 2.8.0
    	 *
    	 * @param string $compressed String to decompress.
    	 * @param int $length The optional length of the compressed data.
    	 * @return string|bool False on failure.
    	 */
    	public static function decompress( $compressed, $length = null ) {
    
    		if ( empty( $compressed ) ) {
    			return $compressed;
    		}
    
    		$decompressed = @gzinflate( $compressed );
    		if ( false !== $decompressed ) {
    			return $decompressed;
    		}
    
    		$decompressed = self::compatible_gzinflate( $compressed );
    		if ( false !== $decompressed ) {
    			return $decompressed;
    		}
    
    		$decompressed = @gzuncompress( $compressed );
    		if ( false !== $decompressed ) {
    			return $decompressed;
    		}
    
    		if ( function_exists( 'gzdecode' ) ) {