Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Http Range Laravel Package

ramsey/http-range

Parse, validate, and work with HTTP Range headers in PHP. ramsey/http-range helps you interpret byte ranges, handle partial content requests, and generate correct range responses for downloads, media streaming, and resumable transfers.

View on GitHub
Deep Wiki
Context7
2.0.0

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

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

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

Added

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

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.
1.1.0

Added

  • Support PHP 8

Changed

  • Bump minimum PHP version to 7.4

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.
1.0.0

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
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus