Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable24] handle stream wrappers in SeekableHttpStream #32776

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/private/Files/Stream/SeekableHttpStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,6 +93,18 @@ private function reconnect(int $start) {
}

$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;
}));
Expand Down