WordPress.org

Make WordPress Core

Ticket #22913: 22913.diff

File 22913.diff, 1.6 KB (added by dd32, 6 months ago)
  • class-http.php

     
    166166                // Construct Cookie: header if any cookies are set 
    167167                WP_Http::buildCookieHeader( $r ); 
    168168 
    169                 if ( WP_Http_Encoding::is_available() ) 
    170                         $r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding(); 
     169                if ( ! isset( $r['headers']['Accept-Encoding'] ) ) 
     170                        $r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding( $url, $r ); 
    171171 
    172172                if ( ( ! is_null( $r['body'] ) && '' != $r['body'] ) || 'POST' == $r['method'] || 'PUT' == $r['method'] ) { 
    173173                        if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) { 
     
    17301745         * 
    17311746         * @return string Types of encoding to accept. 
    17321747         */ 
    1733         public static function accept_encoding() { 
     1748        public static function accept_encoding( $url, $r ) { 
    17341749                $type = array(); 
    1735                 if ( function_exists( 'gzinflate' ) ) 
    1736                         $type[] = 'deflate;q=1.0'; 
    17371750 
    1738                 if ( function_exists( 'gzuncompress' ) ) 
    1739                         $type[] = 'compress;q=0.5'; 
     1751                // The "identity" content-coding is always acceptable by the RFC, we're just specifically allowing it 
     1752                $type[] = 'identity;q=1.0'; 
    17401753 
    1741                 if ( function_exists( 'gzdecode' ) ) 
    1742                         $type[] = 'gzip;q=0.5'; 
     1754                // Disable compression support when saving to file, as otherwise we'll save the compressed data 
     1755                if ( ! $r['stream'] ) { 
     1756                        if ( function_exists( 'gzinflate' ) ) 
     1757                                $type[] = 'deflate;q=1.0'; 
     1758         
     1759                        if ( function_exists( 'gzuncompress' ) ) 
     1760                                $type[] = 'compress;q=0.5'; 
     1761         
     1762                        if ( function_exists( 'gzdecode' ) ) 
     1763                                $type[] = 'gzip;q=0.5'; 
     1764                } 
    17431765 
    17441766                return implode(', ', $type); 
    17451767        }