From 9d02fe01e331bd55eac4f64063be64e98c1028dd Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 17 Jan 2024 09:40:01 +0100 Subject: [PATCH 1/2] add support to create directories with POST --- src/Server.php | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Server.php b/src/Server.php index 9dcd811..2d9d650 100644 --- a/src/Server.php +++ b/src/Server.php @@ -210,27 +210,35 @@ private function handle(string $method, string $path, $contents, $request): Resp } else { $filename = $this->guid(); } - // FIXME: make this list complete for at least the things we'd expect (turtle, n3, jsonld, ntriples, rdf); - switch ($contentType) { - case '': - // FIXME: if no content type was passed, we should reject the request according to the spec; - break; - case "text/plain": - $filename .= ".txt"; - break; - case "text/turtle": - $filename .= ".ttl"; - break; - case "text/html": - $filename .= ".html"; + + $link = $request->getHeaderLine("Link"); + switch ($link) { + case '; rel="type"': + $response = $this->handleCreateDirectoryRequest($response, $path . $filename); break; - case "application/json": - case "application/ld+json": - $filename .= ".json"; + default: + // FIXME: make this list complete for at least the things we'd expect (turtle, n3, jsonld, ntriples, rdf); + switch ($contentType) { + case '': + // FIXME: if no content type was passed, we should reject the request according to the spec; + break; + case "text/plain": + $filename .= ".txt"; + break; + case "text/turtle": + $filename .= ".ttl"; + break; + case "text/html": + $filename .= ".html"; + break; + case "application/json": + case "application/ld+json": + $filename .= ".json"; + break; + } + $response = $this->handleCreateRequest($response, $path . $filename, $contents); break; } - - $response = $this->handleCreateRequest($response, $path . $filename, $contents); } else { $response = $this->handleUpdateRequest($response, $path, $contents); } From 6c14964639b3910e8a9b87a203d2c525758b7afe Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 17 Jan 2024 09:40:33 +0100 Subject: [PATCH 2/2] pass URI to the graph parser so we can parse our own <> entries in the privateTypeIndex --- src/Server.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Server.php b/src/Server.php index 2d9d650..c01ffef 100644 --- a/src/Server.php +++ b/src/Server.php @@ -283,9 +283,7 @@ private function handleSparqlUpdate(Response $response, string $path, $contents) try { // Assuming this is in our native format, turtle - // @CHECKME: Does the Graph Parse here also need an URI? - $graph->parse($data, "turtle"); - // FIXME: Adding this base will allow us to parse <> entries; , $this->baseUrl . $this->basePath . $path), but that breaks the build. + $graph->parse($data, "turtle", $this->baseUrl . $path); // FIXME: Use enums from namespace Pdsinterop\Rdf\Enum\Format instead of 'turtle'? // parse query in contents