From 454ec0f3b9a9c83f161ca43ab09c0ab8f5879e1b Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Fri, 27 Jan 2023 15:12:04 +0100 Subject: [PATCH] Change Server::handleReadRequest() to add "Link" headers instead of replacing them. --- src/Server.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index 5965c26..6d97ea2 100644 --- a/src/Server.php +++ b/src/Server.php @@ -675,8 +675,14 @@ private function handleReadRequest(Response $response, string $path, $contents, $contents = $this->listDirectoryAsTurtle($path); $response->getBody()->write($contents); $response = $response->withHeader("Content-type", "text/turtle"); + // @TODO: These values are also hard-coded in self::listDirectoryAsTurtle(), cleanup might be in order 2023/01/27/BMP + $response = $response->withAddedHeader('Link', [ + '; rel="type"', + '; rel="type"', + '; rel="type"', + ]); $response = $response->withStatus(200); - } elseif(($filesystem->has($path) === false) && (($path == ".meta") || ($path == "/.meta"))) { + } elseif(($filesystem->has($path) === false) && (($path == ".meta") || ($path == "/.meta"))) { $contents = ''; $response->getBody()->write($contents); $response = $response->withHeader("Content-type", "text/turtle"); @@ -760,6 +766,7 @@ private function listDirectoryAsTurtle($path) $turtle = array( "<>" => array( + // @TODO: These values are also hard-coded in self::handleReadRequest(), cleanup might be in order 2023/01/27/BMP "a" => array("ldp:BasicContainer", "ldp:Container", "ldp:Resource"), "ldp:contains" => array() )