diff options
author | Robin Appelman <robin@icewind.nl> | 2022-06-21 18:05:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 18:05:37 +0300 |
commit | 2182b45a2cea2118a5d5cfd483c9406ddff6f6f8 (patch) | |
tree | fdac99040bf7baffe9be5643027aa630e57d576a | |
parent | 2c084ec1e65f1ece6a7eb007b80812f8ecc075ba (diff) | |
parent | 64ed9964ac78f64fc09355722c1c1f153980b489 (diff) |
Merge pull request #32816 from nextcloud/seeakble-http-stream-wrappers-22
[22] handle stream wrappers in SeekableHttpStream
-rw-r--r-- | lib/private/Files/Stream/SeekableHttpStream.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index af797c7720d..820a681bd07 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -24,6 +24,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 @@ -92,6 +93,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; })); |