WordPress.org

Make WordPress Core

Ticket #37073: 37073.diff

File 37073.diff, 1.7 KB (added by borgesbruno, 4 years ago)
  • src/wp-includes/functions.php

     
    632632 * @since 1.5.1
    633633 *
    634634 * @param string $url        URL to retrieve HTTP headers from.
    635  * @param bool   $deprecated Not Used.
    636635 * @return bool|string False on failure, headers on success.
    637636 */
    638 function wp_get_http_headers( $url, $deprecated = false ) {
    639         if ( !empty( $deprecated ) )
    640                 _deprecated_argument( __FUNCTION__, '2.7' );
     637function wp_get_http_headers( $url) {
    641638
    642639        $response = wp_safe_remote_head( $url );
    643640
  • tests/phpunit/tests/external-http/get_headers.php

     
     1<?php
     2/**
     3 * @group external-http
     4 */
     5class Tests_External_HTTP_Get_Headers extends WP_UnitTestCase {
     6
     7        public function test_wp_get_http_headers_should_get_succeed() {
     8
     9                $url = 'https://wordpress.org/';
     10                $http_headers = wp_get_http_headers( $url );
     11
     12                $this->assertInternalType( 'object', $http_headers );
     13                $this->assertArrayHasKey( 'content-type', $http_headers );
     14                $this->assertArrayHasKey( 'date', $http_headers );
     15                $this->assertEquals( 'text/html; charset=utf-8', $http_headers['content-type'] );
     16        }
     17
     18        public function test_wp_get_http_headers_should_fails() {
     19
     20                $url = 'this_is_not_a_valid_url';
     21                $http_headers = wp_get_http_headers( $url );
     22
     23                $this->assertFalse( $http_headers, "This isn't a valid return for a non-valid url and should raise an error" );
     24        }
     25}