ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
XAccelResponseBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Psr\Http\Message\ResponseInterface;
25use Psr\Http\Message\ServerRequestInterface;
26
31{
35 private const DATA = 'data';
39 private const SECURED_DATA = 'secured-data';
43 private const X_ACCEL_REDIRECT_HEADER = 'X-Accel-Redirect';
44
45 public function getName(): string
46 {
47 return 'x-accel';
48 }
49
50 public function buildForStream(
51 ServerRequestInterface $request,
52 ResponseInterface $response,
53 FileStream $stream,
54 ): ResponseInterface {
55 $path_to_file = $stream->getMetadata('uri');
56 if (str_starts_with((string) $path_to_file, './' . self::DATA . '/')) {
57 $path_to_file = str_replace(
58 './' . self::DATA . '/',
59 '/' . self::SECURED_DATA
60 . '/',
62 );
63 }
64
65 return $response->withHeader(
66 self::X_ACCEL_REDIRECT_HEADER,
68 );
69 }
70
71 public function supportPartial(): bool
72 {
73 return true;
74 }
75
76 public function supportStreaming(): bool
77 {
78 return true;
79 }
80
81 public function supportFileDeletion(): bool
82 {
83 return false;
84 }
85
86 public function supportsInlineDelivery(): bool
87 {
88 return true;
89 }
90
91 public function supportsAttachmentDelivery(): bool
92 {
93 return true;
94 }
95}
buildForStream(ServerRequestInterface $request, ResponseInterface $response, FileStream $stream,)
The base interface for all filesystem streams.
Definition: FileStream.php:32
$response
Definition: xapitoken.php:93