From ce5f0cacd13e8d9aad5d1d9f5cf730b0ff823b38 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 8 Jun 2022 17:52:27 +0200 Subject: [PATCH] handle stream wrappers in SeekableHttpStream Signed-off-by: Robin Appelman --- lib/private/Files/Stream/SeekableHttpStream.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index fa6da7a1a53..8e9afb993cd 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -25,6 +25,7 @@ namespace OC\Files\Stream; use Icewind\Streams\File; +use Icewind\Streams\Wrapper; /** * A stream wrapper that uses http range requests to provide a seekable stream for http reading @@ -93,6 +94,18 @@ class SeekableHttpStream implements File { } $responseHead = stream_get_meta_data($this->current)['wrapper_data']; + + while ($responseHead instanceof Wrapper) { + $wrapperOptions = stream_context_get_options($responseHead->context); + foreach ($wrapperOptions as $options) { + if (isset($options['source']) && is_resource($options['source'])) { + $responseHead = stream_get_meta_data($options['source'])['wrapper_data']; + continue 2; + } + } + throw new \Exception("Failed to get source stream from stream wrapper of " . get_class($responseHead)); + } + $rangeHeaders = array_values(array_filter($responseHead, function ($v) { return preg_match('#^content-range:#i', $v) === 1; })); -- 2.39.5