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.

Built from https://develop.svn.wordpress.org/trunk@37428


git-svn-id: http://core.svn.wordpress.org/trunk@37394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue
2016-05-13 04:42:28 +00:00
parent 65f5fe6fb2
commit 37f6e6813a
64 changed files with 7000 additions and 84 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 '';
}