Skip to content

Commit 454ec0f

Browse files
committed
Change Server::handleReadRequest() to add "Link" headers instead of replacing them.
1 parent 4059f0a commit 454ec0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Server.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,14 @@ private function handleReadRequest(Response $response, string $path, $contents,
675675
$contents = $this->listDirectoryAsTurtle($path);
676676
$response->getBody()->write($contents);
677677
$response = $response->withHeader("Content-type", "text/turtle");
678+
// @TODO: These values are also hard-coded in self::listDirectoryAsTurtle(), cleanup might be in order 2023/01/27/BMP
679+
$response = $response->withAddedHeader('Link', [
680+
'<http://www.w3.org/ns/ldp#Container>; rel="type"',
681+
'<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
682+
'<http://www.w3.org/ns/ldp#Resource>; rel="type"',
683+
]);
678684
$response = $response->withStatus(200);
679-
} elseif(($filesystem->has($path) === false) && (($path == ".meta") || ($path == "/.meta"))) {
685+
} elseif(($filesystem->has($path) === false) && (($path == ".meta") || ($path == "/.meta"))) {
680686
$contents = '';
681687
$response->getBody()->write($contents);
682688
$response = $response->withHeader("Content-type", "text/turtle");
@@ -760,6 +766,7 @@ private function listDirectoryAsTurtle($path)
760766

761767
$turtle = array(
762768
"<>" => array(
769+
// @TODO: These values are also hard-coded in self::handleReadRequest(), cleanup might be in order 2023/01/27/BMP
763770
"a" => array("ldp:BasicContainer", "ldp:Container", "ldp:Resource"),
764771
"ldp:contains" => array()
765772
)

0 commit comments

Comments
 (0)