Skip to content

Releases: ramsey/http-range

2.0.0

02 Mar 05:17
2.0.0
1d02a67
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Update the minimum PHP version to 8.2
  • Add type declarations to all properties, method parameters, and method returns
  • The $totalSize parameters and getTotalSize() methods are now typed as float | int | string instead of mixed
  • The getStart(), getEnd(), and getLength() methods on UnitRangeInterface now return float | int | string instead of mixed

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

1.2.1

01 Mar 21:43
1.2.1
d773d9c
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Accept and properly parse spaces within ranges (#7)

1.2.0

01 Mar 21:27
1.2.0
abae41c
Compare
Choose a tag to compare

Added

  • Support the use of psr/http-message, version 2 (#9)

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

1.1.0

08 Aug 19:37
1.1.0
e516e7d
Compare
Choose a tag to compare

Added

  • Support PHP 8

Changed

  • Bump minimum PHP version to 7.4

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

1.0.0

31 Dec 21:21
1.0.0
f4239e0
Compare
Choose a tag to compare

Added

ramsey/http-range provides functionality for parsing HTTP range headers for a variety of range units. Out-of-the-box, ramsey/http-range supports bytes ranges as defined in RFC 7233 § 2.1, as well as basic support for generic range units. The library provides interfaces, abstract classes, and factories, allowing creation of other range units.

Example

ramsey/http-range is designed to be used with PSR-7 RequestInterface objects. Assuming that $request in the following example conforms to this interface, the following example shows how to use this library to parse an HTTP Range header.

The following HTTP request uses a Range header to request the first 500 bytes of the resource at /image/1234.

GET /image/1234 HTTP/1.1
Host: example.com
Range: bytes=0-499

When receiving a request like this, you can parse the Range header using the following.

use Ramsey\Http\Range\Exception\NoRangeException;
use Ramsey\Http\Range\Range;

$filePath = '/path/to/image/1234.jpg';
$filePieces = [];

$range = new Range($request, filesize($filePath));

try {
    // getRanges() always returns an iterable collection of range values,
    // even if there is only one range, as is the case in this example.
    foreach ($range->getUnit()->getRanges() as $rangeValue) {
        $filePieces[] = file_get_contents(
            $filePath,
            false,
            null,
            $rangeValue->getStart(),
            $rangeValue->getLength()
        );
    }
} catch (NoRangeException $e) {
    // This wasn't a range request or the `Range` header was empty.
}

0.1.0-alpha

29 May 18:07
ce1d231
Compare
Choose a tag to compare
0.1.0-alpha Pre-release
Pre-release
Merge pull request #2 from Cloudstek/cloudstek/doc

Fix docblock issues