HTTP API: Replace internals with Requests library.

Requests is a library very similar to WP_HTTP, with a high level of unit test coverage, and has a common lineage and development team. It also supports parallel requests.

See #33055.


git-svn-id: https://develop.svn.wordpress.org/trunk@37428 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue
2016-05-13 04:41:45 +00:00
parent e2329076f3
commit 9074e9f93b
65 changed files with 6999 additions and 92 deletions

View File

@@ -213,8 +213,9 @@ function wp_remote_head($url, $args = array()) {
* @return array The headers of the response. Empty array if incorrect parameter given.
*/
function wp_remote_retrieve_headers( $response ) {
if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
return array();
}
return $response['headers'];
}
@@ -229,11 +230,13 @@ function wp_remote_retrieve_headers( $response ) {
* @return string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.
*/
function wp_remote_retrieve_header( $response, $header ) {
if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
return '';
}
if ( array_key_exists($header, $response['headers']) )
if ( isset( $response['headers'][ $header ] ) ) {
return $response['headers'][$header];
}
return '';
}