Make WordPress Core

Changeset 23601


Ignore:
Timestamp:
03/04/2013 03:33:12 AM (13 years ago)
Author:
dd32
Message:

WP_HTTP: Do not send a Accept-Encoding header when we're streaming to file, or decompression has been disabled by the caller, See #22913

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-http.php

    r23600 r23601  
    167167                WP_Http::buildCookieHeader( $r );
    168168
    169                 if ( ! isset( $r['headers']['Accept-Encoding'] ) && WP_Http_Encoding::is_available() )
    170                         $r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();
     169                if ( ! isset( $r['headers']['Accept-Encoding'] ) ) {
     170                        if ( $encoding = WP_Http_Encoding::accept_encoding( $url, $r ) )
     171                                $r['headers']['Accept-Encoding'] = $encoding;
     172                }
    171173
    172174                if ( ( ! is_null( $r['body'] ) && '' != $r['body'] ) || 'POST' == $r['method'] || 'PUT' == $r['method'] ) {
     
    17311733         * @return string Types of encoding to accept.
    17321734         */
    1733         public static function accept_encoding() {
     1735        public static function accept_encoding( $url, $args ) {
    17341736                $type = array();
    1735                 if ( function_exists( 'gzinflate' ) )
    1736                         $type[] = 'deflate;q=1.0';
    1737 
    1738                 if ( function_exists( 'gzuncompress' ) )
    1739                         $type[] = 'compress;q=0.5';
    1740 
    1741                 if ( function_exists( 'gzdecode' ) )
    1742                         $type[] = 'gzip;q=0.5';
     1737                $compression_enabled = WP_Http_Encoding::is_available();
     1738
     1739                if ( ! $args['decompress'] ) // decompression specifically disabled
     1740                        $compression_enabled = false;
     1741                elseif ( $args['stream'] ) // disable when streaming to file
     1742                        $compression_enabled = false;
     1743
     1744                if ( $compression_enabled ) {
     1745                        if ( function_exists( 'gzinflate' ) )
     1746                                $type[] = 'deflate;q=1.0';
     1747
     1748                        if ( function_exists( 'gzuncompress' ) )
     1749                                $type[] = 'compress;q=0.5';
     1750       
     1751                        if ( function_exists( 'gzdecode' ) )
     1752                                $type[] = 'gzip;q=0.5';
     1753                }
     1754
     1755                $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args );
    17431756
    17441757                return implode(', ', $type);
Note: See TracChangeset for help on using the changeset viewer.