mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-10-09 05:25:31 +00:00
Add assertions for response content type and content encoding
This commit is contained in:
@@ -4401,16 +4401,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$test = new Test();
|
||||
$test->server('json_response', 'POST', [
|
||||
'keys' => [
|
||||
'content-type',
|
||||
'content-encoding',
|
||||
],
|
||||
'values' => [
|
||||
'text/html; charset=utf-8',
|
||||
'gzip',
|
||||
'headers' => [
|
||||
'content-type: text/html; charset=utf-8',
|
||||
'content-encoding: gzip',
|
||||
],
|
||||
'body' => '<html><body>not gzip-encoded</body></html>',
|
||||
]);
|
||||
$this->assertEquals('text/html; charset=utf-8', $test->curl->responseHeaders['content-type']);
|
||||
$this->assertEquals('gzip', $test->curl->responseHeaders['content-encoding']);
|
||||
$this->assertEquals('<html><body>not gzip-encoded</body></html>', $test->curl->response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +181,9 @@ if ($test === 'http_basic_auth') {
|
||||
echo 'OK';
|
||||
exit;
|
||||
} elseif ($test === 'json_response') {
|
||||
if (isset($_POST['keys']) && isset($_POST['values'])) {
|
||||
foreach ($_POST['keys'] as $index => $key) {
|
||||
if (isset($_POST['values'][$index])) {
|
||||
$value = $_POST['values'][$index];
|
||||
header($key . ': ' . $value);
|
||||
}
|
||||
if (isset($_POST['headers'])) {
|
||||
foreach ($_POST['headers'] as $header) {
|
||||
header($header);
|
||||
}
|
||||
} else {
|
||||
if (isset($_POST['key'])) {
|
||||
|
||||
Reference in New Issue
Block a user