Make WordPress Core

Ticket #8620: 8620.diff

File 8620.diff, 4.0 KB (added by DD32, 14 years ago)
  • wp-includes/http.php

     
    18981898 *
    18991899 * @param string $url Site URL to retrieve.
    19001900 * @param array $args Optional. Override the defaults.
    1901  * @return WP_Error|string The body of the response or WP_Error on failure.
     1901 * @return WP_Error|array The response or WP_Error on failure.
    19021902 */
    19031903function wp_remote_request($url, $args = array()) {
    19041904        $objFetchSite = _wp_http_get_object();
     
    19141914 *
    19151915 * @param string $url Site URL to retrieve.
    19161916 * @param array $args Optional. Override the defaults.
    1917  * @return WP_Error|string The body of the response or WP_Error on failure.
     1917 * @return WP_Error|array The response or WP_Error on failure.
    19181918 */
    19191919function wp_remote_get($url, $args = array()) {
    19201920        $objFetchSite = _wp_http_get_object();
     
    19301930 *
    19311931 * @param string $url Site URL to retrieve.
    19321932 * @param array $args Optional. Override the defaults.
    1933  * @return WP_Error|string The body of the response or WP_Error on failure.
     1933 * @return WP_Error|array The response or WP_Error on failure.
    19341934 */
    19351935function wp_remote_post($url, $args = array()) {
    19361936        $objFetchSite = _wp_http_get_object();
     
    19461946 *
    19471947 * @param string $url Site URL to retrieve.
    19481948 * @param array $args Optional. Override the defaults.
    1949  * @return WP_Error|string The body of the response or WP_Error on failure.
     1949 * @return WP_Error|array The response or WP_Error on failure.
    19501950 */
    19511951function wp_remote_head($url, $args = array()) {
    19521952        $objFetchSite = _wp_http_get_object();
     
    19621962 * @return array The headers of the response. Empty array if incorrect parameter given.
    19631963 */
    19641964function wp_remote_retrieve_headers(&$response) {
    1965         if ( ! isset($response['headers']) || ! is_array($response['headers']))
     1965        if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
    19661966                return array();
    19671967
    19681968        return $response['headers'];
     
    19751975 *
    19761976 * @param array $response
    19771977 * @param string $header Header name to retrieve value from.
    1978  * @return array The header value. Empty string on if incorrect parameter given.
     1978 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
    19791979 */
    19801980function wp_remote_retrieve_header(&$response, $header) {
    1981         if ( ! isset($response['headers']) || ! is_array($response['headers']))
     1981        if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
    19821982                return '';
    19831983
    19841984        if ( array_key_exists($header, $response['headers']) )
     
    19951995 * @since 2.7.0
    19961996 *
    19971997 * @param array $response HTTP response.
    1998  * @return array The keys 'code' and 'message' give information on the response.
     1998 * @return string the response code. Empty string on incorrect parameter given.
    19991999 */
    20002000function wp_remote_retrieve_response_code(&$response) {
    2001         if ( ! isset($response['response']) || ! is_array($response['response']))
     2001        if ( is_wp_error($response) ||! isset($response['response']) || ! is_array($response['response']))
    20022002                return '';
    20032003
    20042004        return $response['response']['code'];
     
    20122012 * @since 2.7.0
    20132013 *
    20142014 * @param array $response HTTP response.
    2015  * @return array The keys 'code' and 'message' give information on the response.
     2015 * @return string The response message. Empty string on incorrect parameter given.
    20162016 */
    20172017function wp_remote_retrieve_response_message(&$response) {
    2018         if ( ! isset($response['response']) || ! is_array($response['response']))
     2018        if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
    20192019                return '';
    20202020
    20212021        return $response['response']['message'];
     
    20302030 * @return string The body of the response. Empty string if no body or incorrect parameter given.
    20312031 */
    20322032function wp_remote_retrieve_body(&$response) {
    2033         if ( ! isset($response['body']) )
     2033        if ( is_wp_error($response) || ! isset($response['body']) )
    20342034                return '';
    20352035
    20362036        return $response['body'];