Skip to content

Commit

Permalink
downloadToResponse function
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrime-ru committed Jan 20, 2020
1 parent 0e4e0b8 commit cdcea13
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/MadelineProtoExtensions/ApiExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,8 @@ function() use ($data) {
);
}

private function getByteRange(?string $header) {
$matches = [
'start' => 0,
'end' => -1
];
if ($header) {
preg_match("~bytes=(?'start'\d+)-(?'end'\d*)~", $header, $matches);
}
return [
'start' => (int) $matches['start'],
'end' => (int) $matches['end'] ?: -1
];
}

private function downloadToResponse(array $info) {

public function downloadToResponse(array $info): array
{
$range = $this->getByteRange($this->request->getHeader('Range'));

if ($range['end'] === -1) {
Expand Down Expand Up @@ -475,4 +461,18 @@ private function downloadToResponse(array $info) {
];
}

private function getByteRange(?string $header) {
$matches = [
'start' => 0,
'end' => -1
];
if ($header) {
preg_match("~bytes=(?'start'\d+)-(?'end'\d*)~", $header, $matches);
}
return [
'start' => (int) $matches['start'],
'end' => (int) $matches['end'] ?: -1
];
}

}

0 comments on commit cdcea13

Please sign in to comment.