changeset 322:cca158327c47

added OutOfRangeException
author cin
date Tue, 21 May 2013 10:04:11 +0400
parents 3dc9260017ad
children b56b1ec33b59
files Lib/IMPL/Web/Application/Action.pm Lib/IMPL/Web/OutOfRangeException.pm
diffstat 2 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/Action.pm	Mon May 20 01:14:27 2013 +0400
+++ b/Lib/IMPL/Web/Application/Action.pm	Tue May 21 10:04:11 2013 +0400
@@ -69,6 +69,10 @@
     $this->_launder(scalar( $this->query->url_param($name) ), $rx);
 }
 
+sub urlParams {
+    shift->query->url_param();
+}
+
 sub rawData {
     my ($this, $decode) = @_;
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/OutOfRangeException.pm	Tue May 21 10:04:11 2013 +0400
@@ -0,0 +1,51 @@
+package IMPL::Web::OutOfRangeException;
+use strict;
+
+use IMPL::declare {
+    base => {
+        'IMPL::Web::Exception' => '@_'  
+    },
+};
+
+sub CTOR {
+    my ($this,$range) = @_;
+    
+    #TODO: validate args
+    
+    $this->headers({
+        content_range => { $range->{units} . ' */' . $range->{length} } 
+    });
+}
+
+use IMPL::Resources::Strings {
+    message => 'The specified range is invalid'
+};
+
+sub status {
+    "416 Requested Range Not Satisfiable"
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+C<IMPL::Web::OutOfRangeException>  A server SHOULD return a response with this
+status code if a request included a Range request-header field (section 14.35),
+and none of the range-specifier values in this field overlap the current extent
+of the selected resource, and the request did not include an If-Range
+request-header field. (For byte-ranges, this means that the first- byte-pos of
+all of the byte-range-spec values were greater than the current length of the
+selected resource.)
+
+=head1 DESCRIPTION
+
+When this status code is returned for a byte-range request, the response SHOULD
+include a Content-Range entity-header field specifying the current length of the
+selected resource (see section 14.16). This response MUST NOT use the
+multipart/byteranges content- type. 
+
+=cut
\ No newline at end of file