NAME

HTTP::Promise::Headers::ContentRange - Content-Range Header Field

SYNOPSIS

use HTTP::Promise::Headers::ContentRange;
my $range = HTTP::Promise::Headers::ContentRange->new || 
    die( HTTP::Promise::Headers::ContentRange->error, "\n" );
$range->unit( 'bytes' ):
$range->range_start(500);
$range->range_end(1000);
$range->size(2048);
say $range->as_string;
# or
say "$range";

# 416 Range Not Satisfiable
# <https://tools.ietf.org/html/rfc7233#section-4.4>
$range->start_end( undef );
$range->size(2048);
say "$range";
# bytes */2048

VERSION

v0.1.0

DESCRIPTION

The following description is taken from Mozilla documentation.

Content-Range: bytes 200-1000/67589
# When the complete range is unknown:
Content-Range: bytes 42-1233/*

# The first 500 bytes:
Content-Range: bytes 0-499/1234
# The second 500 bytes:
Content-Range: bytes 500-999/1234
# All except for the first 500 bytes:
Content-Range: bytes 500-1233/1234
# The last 500 bytes:
Content-Range: bytes 734-1233/1234
# Unsatisfiable range value
Content-Range: bytes */1234

METHODS

as_string

Returns a string representation of the object.

If both range-start and range-end properties are undef, they will be replaced by a * (wildcard)

If size property is undef it will be replaced by a * (wildcard)

range_end

An integer in the given unit indicating the end position (zero-indexed & inclusive) of the requested range.

range_start

An integer in the given unit indicating the start position (zero-indexed & inclusive) of the request range.

size

The total length of the document (or '*' if unknown).

start_end

This is a convenience method to set both the range-start and range-end property.

unit

The unit in which ranges are specified. This is usually bytes.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Accept-Range, If-Range, Range

See rfc7233, section 4.2 and Mozilla documentation

HTTP::Promise, HTTP::Promise::Request, HTTP::Promise::Response, HTTP::Promise::Message, HTTP::Promise::Entity, HTTP::Promise::Headers, HTTP::Promise::Body, HTTP::Promise::Body::Form, HTTP::Promise::Body::Form::Data, HTTP::Promise::Body::Form::Field, HTTP::Promise::Status, HTTP::Promise::MIME, HTTP::Promise::Parser, HTTP::Promise::IO, HTTP::Promise::Stream, HTTP::Promise::Exception

COPYRIGHT & LICENSE

Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.