Skip to content

Commit

Permalink
Merge pull request #23 from pdsinterop/fix/add-link-headers
Browse files Browse the repository at this point in the history
Change Server::handleReadRequest() to add "Link" headers instead of replacing them.
  • Loading branch information
ylebre authored Jan 27, 2023
2 parents 4059f0a + 454ec0f commit 71f8b04
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
'<http://www.w3.org/ns/ldp#Container>; rel="type"',
'<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
'<http://www.w3.org/ns/ldp#Resource>; 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");
Expand Down Expand Up @@ -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()
)
Expand Down

0 comments on commit 71f8b04

Please sign in to comment.