Make WordPress Core

Ticket #8620: http.2.diff

File http.2.diff, 2.2 KB (added by momo360modena, 14 years ago)

Props return WP_Error.

  • wp-includes/http.php

     
    11761176 * @return array The headers of the response. Empty array if incorrect parameter given.
    11771177 */
    11781178function wp_remote_retrieve_headers(&$response) {
    1179         if ( ! isset($response['headers']) || ! is_array($response['headers']))
     1179        if ( is_wp_error($response) )
     1180                return $response;
     1181               
     1182        if ( ! isset($response['headers']) || ! is_array($response['headers']) )
    11801183                return array();
    11811184
    11821185        return $response['headers'];
     
    11921195 * @return array The header value. Empty string on if incorrect parameter given.
    11931196 */
    11941197function wp_remote_retrieve_header(&$response, $header) {
    1195         if ( ! isset($response['headers']) || ! is_array($response['headers']))
     1198        if ( is_wp_error($response) )
     1199                return $response;
     1200               
     1201        if ( ! isset($response['headers']) || ! is_array($response['headers']) )
    11961202                return '';
    11971203
    11981204        if ( array_key_exists($header, $response['headers']) )
     
    12121218 * @return array The keys 'code' and 'message' give information on the response.
    12131219 */
    12141220function wp_remote_retrieve_response_code(&$response) {
    1215         if ( ! isset($response['response']) || ! is_array($response['response']))
     1221        if ( is_wp_error($response) )
     1222                return $response;
     1223       
     1224        if ( ! isset($response['response']) || ! is_array($response['response']) )
    12161225                return '';
    12171226
    12181227        return $response['response']['code'];
     
    12291238 * @return array The keys 'code' and 'message' give information on the response.
    12301239 */
    12311240function wp_remote_retrieve_response_message(&$response) {
    1232         if ( ! isset($response['response']) || ! is_array($response['response']))
     1241        if ( is_wp_error($response) )
     1242                return $response;
     1243               
     1244        if ( ! isset($response['response']) || ! is_array($response['response']) )
    12331245                return '';
    12341246
    12351247        return $response['response']['message'];
     
    12441256 * @return string The body of the response. Empty string if no body or incorrect parameter given.
    12451257 */
    12461258function wp_remote_retrieve_body(&$response) {
     1259        if ( is_wp_error($response) )
     1260                return $response;
     1261               
    12471262        if ( ! isset($response['body']) )
    12481263                return '';
    12491264