about summary refs log tree commit diff stats
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-28 06:59:47 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-28 06:59:47 +0300
commit78bfc53e084afddcff6450173ae594ee8df279ac (patch)
treeab29a1be6b046e61306393112fb65cc2c9e9d12d /classes
parent69b46e2fd39294d347206edd8b4ea01b749bdb51 (diff)
downloadthe-epube-78bfc53e084afddcff6450173ae594ee8df279ac.tar.gz
the-epube-78bfc53e084afddcff6450173ae594ee8df279ac.tar.xz
try setting content-type conditionally, remove duplicate testcase code
Diffstat (limited to 'classes')
-rw-r--r--classes/Response.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/classes/Response.php b/classes/Response.php
index a0620ae..8d32496 100644
--- a/classes/Response.php
+++ b/classes/Response.php
@@ -6,6 +6,7 @@ class Response
 	/** @var array<string, string> */
 	private array $headers = [];
 	private string $body = '';
+	private string $contentType = "text/json";
 
 	public function withStatus(int $code, string $reasonPhrase = ''): self
 	{
@@ -35,11 +36,20 @@ class Response
 
 	public function send(): void
 	{
+		$contentTypeFound = false;
+
 		if ($this->headers) {
 			foreach ($this->headers as $name => $value) {
 				header("$name: $value");
+
+				if (strtolower($name) === "content-type")
+					$contentTypeFound = true;
 			}
 		}
+
+		if (!$contentTypeFound)
+			header("Content-type: {$this->contentType}");
+
 		http_response_code($this->status);
 		echo $this->body;
 	}