Make WordPress Core

Ticket #8618: 8618.diff

File 8618.diff, 7.7 KB (added by jacobsantos, 16 years ago)

Return string only and fix bug with loop.

  • http.php

     
    88 *
    99 * @package WordPress
    1010 * @subpackage HTTP
    11  * @since 2.7
     11 * @since 2.7.0
    1212 * @author Jacob Santos <wordpress@santosj.name>
    1313 */
    1414
     
    3232 *
    3333 * @package WordPress
    3434 * @subpackage HTTP
    35  * @since 2.7
     35 * @since 2.7.0
    3636 */
    3737class WP_Http {
    3838
    3939        /**
    4040         * PHP4 style Constructor - Calls PHP5 Style Constructor
    4141         *
    42          * @since 2.7
     42         * @since 2.7.0
    4343         * @return WP_Http
    4444         */
    4545        function WP_Http() {
     
    5555         * The transport are setup to save time. This should only be called once, so
    5656         * the overhead should be fine.
    5757         *
    58          * @since 2.7
     58         * @since 2.7.0
    5959         * @return WP_Http
    6060         */
    6161        function __construct() {
     
    8181         * period of time, or established connection failed because connected host
    8282         * has failed to respond."
    8383         *
    84          * @since 2.7
     84         * @since 2.7.0
    8585         * @access private
    8686         *
    8787         * @param array $args Request args, default us an empty array
     
    129129         * to send content, but the streams transport can. This is a limitation that
    130130         * is addressed here, by just not including that transport.
    131131         *
    132          * @since 2.7
     132         * @since 2.7.0
    133133         * @access private
    134134         *
    135135         * @param array $args Request args, default us an empty array
     
    201201         * continue going after making the request.
    202202         *
    203203         * @access public
    204          * @since 2.7
     204         * @since 2.7.0
    205205         *
    206206         * @param string $url URI resource.
    207207         * @param str|array $args Optional. Override the defaults.
     
    273273         * Used for sending data that is expected to be in the body.
    274274         *
    275275         * @access public
    276          * @since 2.7
     276         * @since 2.7.0
    277277         *
    278278         * @param string $url URI resource.
    279279         * @param str|array $args Optional. Override the defaults.
     
    291291         * Used for sending data that is expected to be in the body.
    292292         *
    293293         * @access public
    294          * @since 2.7
     294         * @since 2.7.0
    295295         *
    296296         * @param string $url URI resource.
    297297         * @param str|array $args Optional. Override the defaults.
     
    309309         * Used for sending data that is expected to be in the body.
    310310         *
    311311         * @access public
    312          * @since 2.7
     312         * @since 2.7.0
    313313         *
    314314         * @param string $url URI resource.
    315315         * @param str|array $args Optional. Override the defaults.
     
    326326         *
    327327         * @access public
    328328         * @static
    329          * @since 2.7
     329         * @since 2.7.0
    330330         *
    331331         * @param string $strResponse The full response string
    332332         * @return array Array with 'headers' and 'body' keys.
     
    345345         *
    346346         * @access public
    347347         * @static
    348          * @since 2.7
     348         * @since 2.7.0
    349349         *
    350350         * @param string|array $headers
    351351         * @return array Processed string headers
     
    386386         *
    387387         * @todo Add support for footer chunked headers.
    388388         * @access public
    389          * @since 2.7
     389         * @since 2.7.0
    390390         * @static
    391391         *
    392392         * @param string $body Body content
     
    408408
    409409                        if ( $hasChunk ) {
    410410                                if ( empty($match[1]) ) {
    411                                         return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     411                                        return $body;
    412412                                }
    413413
    414414                                $length = hexdec( $match[1] );
     
    425425                                        break;
    426426                                }
    427427                        } else {
    428                                 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     428                                return $body;
    429429                        }
    430                 } while ( false === $done );
     430                } while ( true === $done );
    431431        }
    432432}
    433433
     
    439439 *
    440440 * @package WordPress
    441441 * @subpackage HTTP
    442  * @since 2.7
     442 * @since 2.7.0
    443443 */
    444444class WP_Http_Fsockopen {
    445445        /**
     
    583583        /**
    584584         * Whether this class can be used for retrieving an URL.
    585585         *
    586          * @since 2.7
     586         * @since 2.7.0
    587587         * @static
    588588         * @return boolean False means this class can not be used, true means it can.
    589589         */
     
    607607 *
    608608 * @package WordPress
    609609 * @subpackage HTTP
    610  * @since 2.7
     610 * @since 2.7.0
    611611 */
    612612class WP_Http_Fopen {
    613613        /**
     
    621621         * @see WP_Http::retrieve For default options descriptions.
    622622         *
    623623         * @access public
    624          * @since 2.7
     624         * @since 2.7.0
    625625         *
    626626         * @param string $url URI resource.
    627627         * @param str|array $args Optional. Override the defaults.
     
    693693        /**
    694694         * Whether this class can be used for retrieving an URL.
    695695         *
     696         * @since 2.7.0
    696697         * @static
    697698         * @return boolean False means this class can not be used, true means it can.
    698699         */
     
    714715 *
    715716 * @package WordPress
    716717 * @subpackage HTTP
    717  * @since 2.7
     718 * @since 2.7.0
    718719 */
    719720class WP_Http_Streams {
    720721        /**
    721722         * Send a HTTP request to a URI using streams with fopen().
    722723         *
    723724         * @access public
    724          * @since 2.7
     725         * @since 2.7.0
    725726         *
    726727         * @param string $url
    727728         * @param str|array $args Optional. Override the defaults.
     
    817818         *
    818819         * @static
    819820         * @access public
    820          * @since 2.7
     821         * @since 2.7.0
    821822         *
    822823         * @return boolean False means this class can not be used, true means it can.
    823824         */
     
    842843 *
    843844 * @package WordPress
    844845 * @subpackage HTTP
    845  * @since 2.7
     846 * @since 2.7.0
    846847 */
    847848class WP_Http_ExtHTTP {
    848849        /**
     
    932933         * Whether this class can be used for retrieving an URL.
    933934         *
    934935         * @static
    935          * @since 2.7
     936         * @since 2.7.0
    936937         *
    937938         * @return boolean False means this class can not be used, true means it can.
    938939         */
     
    958959         * Send a HTTP request to a URI using cURL extension.
    959960         *
    960961         * @access public
    961          * @since 2.7
     962         * @since 2.7.0
    962963         *
    963964         * @param string $url
    964965         * @param str|array $args Optional. Override the defaults.
     
    10571058         * Whether this class can be used for retrieving an URL.
    10581059         *
    10591060         * @static
    1060          * @since 2.7
     1061         * @since 2.7.0
    10611062         *
    10621063         * @return boolean False means this class can not be used, true means it can.
    10631064         */
     
    10721073/**
    10731074 * Returns the initialized WP_Http Object
    10741075 *
    1075  * @since 2.7
     1076 * @since 2.7.0
    10761077 * @access private
    10771078 *
    10781079 * @return WP_Http HTTP Transport object.
     
    11231124 *
    11241125 * @see wp_remote_request() For more information on the response array format.
    11251126 *
    1126  * @since 2.7
     1127 * @since 2.7.0
    11271128 *
    11281129 * @param string $url Site URL to retrieve.
    11291130 * @param array $args Optional. Override the defaults.
     
    11401141 *
    11411142 * @see wp_remote_request() For more information on the response array format.
    11421143 *
    1143  * @since 2.7
     1144 * @since 2.7.0
    11441145 *
    11451146 * @param string $url Site URL to retrieve.
    11461147 * @param array $args Optional. Override the defaults.
     
    11561157 *
    11571158 * @see wp_remote_request() For more information on the response array format.
    11581159 *
    1159  * @since 2.7
     1160 * @since 2.7.0
    11601161 *
    11611162 * @param string $url Site URL to retrieve.
    11621163 * @param array $args Optional. Override the defaults.
     
    11701171/**
    11711172 * Retrieve only the headers from the raw response.
    11721173 *
    1173  * @since 2.7
     1174 * @since 2.7.0
    11741175 *
    11751176 * @param array $response HTTP response.
    11761177 * @return array The headers of the response. Empty array if incorrect parameter given.
     
    11851186/**
    11861187 * Retrieve a single header by name from the raw response.
    11871188 *
    1188  * @since 2.7
     1189 * @since 2.7.0
    11891190 *
    11901191 * @param array $response
    11911192 * @param string $header Header name to retrieve value from.
     
    12061207 *
    12071208 * Will return an empty array if incorrect parameter value is given.
    12081209 *
    1209  * @since 2.7
     1210 * @since 2.7.0
    12101211 *
    12111212 * @param array $response HTTP response.
    12121213 * @return array The keys 'code' and 'message' give information on the response.
     
    12231224 *
    12241225 * Will return an empty array if incorrect parameter value is given.
    12251226 *
    1226  * @since 2.7
     1227 * @since 2.7.0
    12271228 *
    12281229 * @param array $response HTTP response.
    12291230 * @return array The keys 'code' and 'message' give information on the response.
     
    12381239/**
    12391240 * Retrieve only the body from the raw response.
    12401241 *
    1241  * @since 2.7
     1242 * @since 2.7.0
    12421243 *
    12431244 * @param array $response HTTP response.
    12441245 * @return string The body of the response. Empty string if no body or incorrect parameter given.