Add assertions for response content type and content encoding

This commit is contained in:
Zach Borboa
2022-12-10 11:50:37 -08:00
parent e70395af88
commit c5a471ff2d
2 changed files with 8 additions and 13 deletions
+5 -7
View File
@@ -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);
}
}
+3 -6
View File
@@ -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'])) {