From 1557cefbd76257ceb830f65806831b490faf0acc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 4 Jan 2016 10:45:54 +0100 Subject: Fixes #410 - Retrieve title fails in multiple cases * `get_http_url()` renamed to `get_http_response()`. * Use the same HTTP context to retrieve response headers and content. * Follow HTTP 301 and 302 redirections to retrieve the title (default max 3 redirections). * Add `LinkUtils` to extract titles and charset. * Try to retrieve charset from HTTP headers first (new), then HTML content. * Use mb_string to re-encode title if necessary. --- tests/Url/UrlTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/Url/UrlTest.php') diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php index af6daaa4..425327ed 100644 --- a/tests/Url/UrlTest.php +++ b/tests/Url/UrlTest.php @@ -156,4 +156,22 @@ class UrlTest extends PHPUnit_Framework_TestCase $this->assertEquals($strOn, add_trailing_slash($strOn)); $this->assertEquals($strOn, add_trailing_slash($strOff)); } + + /** + * Test valid HTTP url. + */ + function testUrlIsHttp() + { + $url = new Url(self::$baseUrl); + $this->assertTrue($url->isHttp()); + } + + /** + * Test non HTTP url. + */ + function testUrlIsNotHttp() + { + $url = new Url('ftp://save.tld/mysave'); + $this->assertFalse($url->isHttp()); + } } -- cgit v1.2.3