Ticket #8620: 8620.patch
File 8620.patch, 3.4 KB (added by , 15 years ago) |
---|
-
wp-includes/http.php
1964 1964 * @since 2.7.0 1965 1965 * 1966 1966 * @param array $response HTTP response. 1967 * @return array The headers of the response. Empty array if incorrect parameter given.1967 * @return array The headers of the response. Empty array if incorrect parameter (e.g. a WP_Error) given. 1968 1968 */ 1969 1969 function wp_remote_retrieve_headers(&$response) { 1970 if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))1971 return array();1972 1973 return $response['headers'];1970 $sanitzed = (array) $response; 1971 if ( isset($sanitzed['headers']) && is_array($sanitzed['headers']) ) 1972 return $sanitzed['headers']; 1973 return array(); 1974 1974 } 1975 1975 1976 1976 /** … … 1980 1980 * 1981 1981 * @param array $response 1982 1982 * @param string $header Header name to retrieve value from. 1983 * @return string The header value. Empty string on if incorrect parameter given , or if the header doesnt exist.1983 * @return string The header value. Empty string on if incorrect parameter given (e.g. a WP_Error), or if the header doesnt exist. 1984 1984 */ 1985 1985 function wp_remote_retrieve_header(&$response, $header) { 1986 if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers'])) 1987 return ''; 1988 1989 if ( array_key_exists($header, $response['headers']) ) 1990 return $response['headers'][$header]; 1991 1992 return ''; 1986 $sanitzed = (array) $response; 1987 return isset($sanitzed['headers'][$header]) ? $sanitzed['headers'][$header] : ''; 1993 1988 } 1994 1989 1995 1990 /** … … 2000 1995 * @since 2.7.0 2001 1996 * 2002 1997 * @param array $response HTTP response. 2003 * @return string the response code. Empty string on incorrect parameter given.1998 * @return string the response code. Empty string on incorrect parameter (e.g. a WP_Error) given. 2004 1999 */ 2005 2000 function wp_remote_retrieve_response_code(&$response) { 2006 if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) 2007 return ''; 2008 2009 return $response['response']['code']; 2001 $sanitzed = (array) $response; 2002 return isset($sanitzed['response']['code']) ? $sanitzed['response']['code'] : ''; 2010 2003 } 2011 2004 2012 2005 /** … … 2017 2010 * @since 2.7.0 2018 2011 * 2019 2012 * @param array $response HTTP response. 2020 * @return string The response message. Empty string on incorrect parameter given.2013 * @return string The response message. Empty string on incorrect parameter (e.g. a WP_Error) given. 2021 2014 */ 2022 2015 function wp_remote_retrieve_response_message(&$response) { 2023 if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) 2024 return ''; 2025 2026 return $response['response']['message']; 2016 $sanitzed = (array) $response; 2017 return isset($sanitzed['response']['message']) ? $sanitzed['response']['message'] : ''; 2027 2018 } 2028 2019 2029 2020 /** … … 2032 2023 * @since 2.7.0 2033 2024 * 2034 2025 * @param array $response HTTP response. 2035 * @return string The body of the response. Empty string if no body or incorrect parameter given.2026 * @return string The body of the response. Empty string if no body or incorrect parameter (e.g. a WP_Error) given. 2036 2027 */ 2037 2028 function wp_remote_retrieve_body(&$response) { 2038 if ( is_wp_error($response) || ! isset($response['body']) ) 2039 return ''; 2040 2041 return $response['body']; 2029 $sanitzed = (array) $response; 2030 return isset($sanitzed['body']) ? $sanitzed['body'] : ''; 2042 2031 } 2043 2032 2044 2033 ?>