mirror of
https://github.com/friendica/friendica
synced 2025-04-26 03:10:13 +00:00
Fix IHTTPResult::getHeader/s()
- Split functionality "getHeader()" and "getHeaders()" analog to IMessageInterface::getHeader/s() - Fix functionality at various places - Adapt CurlResultTest
This commit is contained in:
parent
fff94563d7
commit
933ea7c9ce
11 changed files with 96 additions and 28 deletions
|
@ -53,6 +53,7 @@ class CurlResultTest extends TestCase
|
|||
public function testNormal()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
|
@ -65,7 +66,7 @@ class CurlResultTest extends TestCase
|
|||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertFalse($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local', $curlResult->getUrl());
|
||||
|
@ -80,6 +81,7 @@ class CurlResultTest extends TestCase
|
|||
public function testRedirect()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
|
@ -93,7 +95,7 @@ class CurlResultTest extends TestCase
|
|||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertTrue($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it', $curlResult->getUrl());
|
||||
|
@ -106,6 +108,7 @@ class CurlResultTest extends TestCase
|
|||
public function testTimeout()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
|
@ -119,7 +122,7 @@ class CurlResultTest extends TestCase
|
|||
$this->assertFalse($curlResult->isSuccess());
|
||||
$this->assertTrue($curlResult->isTimeout());
|
||||
$this->assertFalse($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it', $curlResult->getRedirectUrl());
|
||||
|
@ -134,6 +137,7 @@ class CurlResultTest extends TestCase
|
|||
public function testRedirectHeader()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.redirect');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.redirect.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
|
@ -146,7 +150,7 @@ class CurlResultTest extends TestCase
|
|||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertTrue($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it?key=value', $curlResult->getUrl());
|
||||
|
@ -204,7 +208,7 @@ class CurlResultTest extends TestCase
|
|||
'url' => 'https://test.local'
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($curlResult->getHeader());
|
||||
$this->assertNotEmpty($curlResult->getHeaders());
|
||||
$this->assertEmpty($curlResult->getHeader('wrongHeader'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue