mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 19:24:34 +00:00
Deprecate wp_get_http() - function isn't used anywhere (apart from itself).
Props swissspidy. Fixes #33709. git-svn-id: https://develop.svn.wordpress.org/trunk@33969 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -42,45 +42,37 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
|
||||
|
||||
function test_get_request() {
|
||||
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
|
||||
$file = tempnam('/tmp', 'testfile');
|
||||
|
||||
$headers = wp_get_http($url, $file);
|
||||
$response = wp_remote_get( $url );
|
||||
$headers = wp_remote_retrieve_headers( $response );
|
||||
|
||||
// should return the same headers as a head request
|
||||
$this->assertInternalType( 'array', $headers, "Reply wasn't array." );
|
||||
$this->assertEquals( 'image/jpeg', $headers['content-type'] );
|
||||
$this->assertEquals( '40148', $headers['content-length'] );
|
||||
$this->assertEquals( '200', $headers['response'] );
|
||||
|
||||
// make sure the file is ok
|
||||
$this->assertEquals( 40148, filesize($file) );
|
||||
$this->assertEquals( 'b0371a0fc575fcf77f62cd298571f53b', md5_file($file) );
|
||||
$this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
|
||||
}
|
||||
|
||||
function test_get_redirect() {
|
||||
// this will redirect to asdftestblog1.files.wordpress.com
|
||||
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
|
||||
$file = tempnam('/tmp', 'testfile');
|
||||
|
||||
$headers = wp_get_http($url, $file);
|
||||
$response = wp_remote_get( $url );
|
||||
$headers = wp_remote_retrieve_headers( $response );
|
||||
|
||||
// should return the same headers as a head request
|
||||
$this->assertInternalType( 'array', $headers, "Reply wasn't array." );
|
||||
$this->assertEquals( 'image/jpeg', $headers['content-type'] );
|
||||
$this->assertEquals( '40148', $headers['content-length'] );
|
||||
$this->assertEquals( '200', $headers['response'] );
|
||||
|
||||
// make sure the file is ok
|
||||
$this->assertEquals( 40148, filesize($file) );
|
||||
$this->assertEquals( 'b0371a0fc575fcf77f62cd298571f53b', md5_file($file) );
|
||||
$this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
|
||||
}
|
||||
|
||||
function test_get_redirect_limit_exceeded() {
|
||||
// this will redirect to asdftestblog1.files.wordpress.com
|
||||
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
|
||||
$file = tempnam('/tmp', 'testfile');
|
||||
|
||||
// pretend we've already redirected 5 times
|
||||
$headers = wp_get_http( $url, $file, 6 );
|
||||
$this->assertFalse( $headers );
|
||||
$response = wp_remote_get( $url, array( 'redirection' => -1 ) );
|
||||
$this->assertWPError( $response );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user