HTTP API: Switch back to returning an array.

The array-compatibility object we started returning in r37428 unfortunately isn't enough like an array. In particular, `is_array()` checks fail, despite the object implementing ArrayAccess. Mea culpa.

This moves the WP_HTTP_Response object to a new http_response key in the array, and changes the value back to an actual array.

Fixes #37097.
See #33055.


git-svn-id: https://develop.svn.wordpress.org/trunk@37989 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue
2016-07-06 17:50:44 +00:00
parent 3edf3be241
commit 194c8d0e33
3 changed files with 31 additions and 85 deletions

View File

@@ -24,6 +24,15 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
$this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
}
/**
* @depends test_head_request
*/
function test_returns_array() {
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
$response = wp_remote_head( $url );
$this->assertInternalType( 'array', $response );
}
function test_head_redirect() {
// this url will 301 redirect
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';