You are here

function httprl_get_last_byte_from_range in HTTP Parallel Request & Threading Library 7

Same name and namespace in other branches
  1. 6 httprl.module \httprl_get_last_byte_from_range()

Given an array of ranges, get the last byte we need to download.

Parameters

array $ranges: Multi dimensional array

Return value

int|null NULL: Get all values; int: last byte to download.

1 call to httprl_get_last_byte_from_range()
httprl_send_request in ./httprl.module
Perform many HTTP requests.

File

./httprl.module, line 2050
HTTP Parallel Request Library module.

Code

function httprl_get_last_byte_from_range($ranges) {
  $max = 0;
  if (empty($ranges)) {
    return NULL;
  }
  foreach ($ranges as $range) {
    if (!is_numeric($range['start']) || !is_numeric($range['end'])) {
      return NULL;
    }
    $max = max($range['end'] + 1, $max);
  }
  return $max;
}