| 1 | package HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable; | ||
| 2 | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 3 | $HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable::VERSION = '0.027'; | ||
| 4 | use Types::Standard qw(Str); | ||
| 5 | |||
| 6 | use Moo::Role; | ||
| 7 | |||
| 8 | with( | ||
| 9 | 'HTTP::Throwable', | ||
| 10 | 'HTTP::Throwable::Role::BoringText', | ||
| 11 | ); | ||
| 12 | |||
| 13 | sub default_status_code { 416 } | ||
| 14 | sub default_reason { 'Requested Range Not Satisfiable' } | ||
| 15 | |||
| 16 | has 'content_range' => ( is => 'ro', isa => Str ); | ||
| 17 | |||
| 18 | around 'build_headers' => sub { | ||
| 19 | my $next = shift; | ||
| 20 | my $self = shift; | ||
| 21 | my $headers = $self->$next( @_ ); | ||
| 22 | if ( my $content_range = $self->content_range ) { | ||
| 23 | push @$headers => ('Content-Range' => $content_range); | ||
| 24 | } | ||
| 25 | $headers; | ||
| 26 | }; | ||
| 27 | |||
| 28 | no Moo::Role; 1; | ||
| 29 | |||
| 30 | =pod | ||
| 31 | |||
| 32 | =encoding UTF-8 | ||
| 33 | |||
| 34 | =head1 NAME | ||
| 35 | |||
| 36 | HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable - 416 Requested Range Not Satisfiable | ||
| 37 | |||
| 38 | =head1 VERSION | ||
| 39 | |||
| 40 | version 0.027 | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | A server SHOULD return a response with this status code if a | ||
| 45 | request included a Range request-header field, and none of the | ||
| 46 | range-specifier values in this field overlap the current extent | ||
| 47 | of the selected resource, and the request did not include an | ||
| 48 | If-Range request-header field. (For byte-ranges, this means that | ||
| 49 | the first-byte-pos of all of the byte-range-spec values were greater | ||
| 50 | than the current length of the selected resource.) | ||
| 51 | |||
| 52 | When this status code is returned for a byte-range request, the | ||
| 53 | response SHOULD include a Content-Range entity-header field specifying | ||
| 54 | the current length of the selected resource. This response MUST NOT | ||
| 55 | use the multipart/byteranges content-type. | ||
| 56 | |||
| 57 | =head1 AUTHORS | ||
| 58 | |||
| 59 | =over 4 | ||
| 60 | |||
| 61 | =item * | ||
| 62 | |||
| 63 | Stevan Little <stevan.little@iinteractive.com> | ||
| 64 | |||
| 65 | =item * | ||
| 66 | |||
| 67 | Ricardo Signes <rjbs@cpan.org> | ||
| 68 | |||
| 69 | =back | ||
| 70 | |||
| 71 | =head1 COPYRIGHT AND LICENSE | ||
| 72 | |||
| 73 | This software is copyright (c) 2011 by Infinity Interactive, Inc. | ||
| 74 | |||
| 75 | This is free software; you can redistribute it and/or modify it under | ||
| 76 | the same terms as the Perl 5 programming language system itself. | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | __END__ |