Skip to content

Commit 9bc79cc

Browse files
authored
Merge pull request #1 from trellis-ldp/a-few-modifications
Better file response output
2 parents 1982314 + 3b2c7a6 commit 9bc79cc

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ init:
77
- SET PATH=C:\Program Files\OpenSSL;C:\tools\php71;%PATH%
88
- SET COMPOSER_NO_INTERACTION=1
99

10+
environment:
11+
TRELLIS_CONFIG_DIR: test/resources/config/
12+
1013
install:
1114
- ps: Set-Service wuauserv -StartupType Manual
1215
- cinst -y OpenSSL.Light

settings.yml.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sourceDirectory: /mnt/data/ldp/
2-
template: default.twig
2+
template: default.html.twig
33
defaultRdfFormat: turtle
44
extraPropertiesFilename: properties
55
contentDisposition: false

src/Model/NonRDFSource.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use App\Trellis\StaticLdp\Provider\StaticLdpProvider;
66
use Silex\Application;
7+
use Symfony\Component\HttpFoundation\BinaryFileResponse;
78
use Symfony\Component\HttpFoundation\Request;
89
use Symfony\Component\HttpFoundation\Response;
9-
use Symfony\Component\HttpFoundation\StreamedResponse;
1010
use Twig\Environment;
1111

1212
/**
@@ -44,11 +44,7 @@ public function respond(Request $request, Environment $twig_provider, array $opt
4444
$res->headers->set("Link", $link, false);
4545
}
4646
}
47-
$filename = $this->path;
48-
$stream = function () use ($filename) {
49-
readfile($filename);
50-
};
51-
return new StreamedResponse($stream, 200, $res->headers->all());
47+
return new BinaryFileResponse($this->path, 200, $res->headers->all());
5248
}
5349
return $res;
5450
}

src/Model/RDFSource.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use App\TrellisConfiguration;
66
use App\Model\Resource;
7+
use Symfony\Component\HttpFoundation\BinaryFileResponse;
78
use Symfony\Component\HttpFoundation\Request;
89
use Symfony\Component\HttpFoundation\Response;
9-
use Symfony\Component\HttpFoundation\StreamedResponse;
1010
use Twig\Environment;
1111

1212
/**
@@ -47,11 +47,7 @@ public function respond(Request $request, Environment $twig_provider, array $opt
4747
break;
4848
}
4949
if ($this->canStream($responseFormat)) {
50-
$filename = $this->path;
51-
$stream = function () use ($filename) {
52-
readfile($filename);
53-
};
54-
return new StreamedResponse($stream, 200, $res->headers->all());
50+
return new BinaryFileResponse($this->path, 200, $res->headers->all());
5551
} else {
5652
$graph = new \EasyRdf_Graph();
5753
$graph->parseFile($this->path, $this->getInputFormat($this->path), $request->getURI());

src/Model/Resource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function getResponseMimeType(Request $request)
224224
}
225225
}
226226
}
227-
return "text/turtle";
227+
return "text/turtle; charset=UTF-8";
228228
}
229229

230230
protected function getInputFormat($path)

src/TrellisConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getConfigTreeBuilder()
4343
->end()
4444
->defaultValue([
4545
"turtle" => [
46-
"mimeType" => "text/turtle",
46+
"mimeType" => "text/turtle; charset=UTF-8",
4747
"extension" => "ttl"
4848
],
4949
"jsonld" => [

0 commit comments

Comments
 (0)