File Coverage

blib/lib/HTTP/Exception/3XX.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package HTTP::Exception::3XX;
2             $HTTP::Exception::3XX::VERSION = '0.04007';
3 27     27   830 use strict;
  27         46  
  27         539  
4 27     27   88 use warnings;
  27         35  
  27         499  
5 27     27   90 use base 'HTTP::Exception::Base';
  27         35  
  27         5487  
6              
7             sub is_info () { '' }
8             sub is_success () { '' }
9             sub is_redirect () { 1 }
10             sub is_error () { '' }
11             sub is_client_error () { '' }
12             sub is_server_error () { '' }
13              
14             sub location {
15 16 100   16 1 278 $_[0]->{location} = $_[1] if (@_ > 1);
16 16         34 return $_[0]->{location};
17             }
18              
19             sub Fields {
20 163     163 1 73328 my $self = shift;
21 163         491 my @fields = $self->SUPER::Fields();
22             # TODO: default-value or required, maybe alter new
23 163         295 push @fields, qw(location); # additional Fields
24 163         485 return @fields;
25             }
26              
27             1;
28              
29              
30             =head1 NAME
31              
32             HTTP::Exception::3XX - Base Class for 3XX (redirect) Exceptions
33              
34             =head1 VERSION
35              
36             version 0.04007
37              
38             =head1 SYNOPSIS
39              
40             use HTTP::Exception;
41              
42             # all are exactly the same
43             HTTP::Exception->throw(301, location => 'google.com');
44             HTTP::Exception::301->throw(location => 'google.com');
45             HTTP::Exception::MOVED_PERMANENTLY->throw(location => 'google.com');
46              
47             # and in your favourite Webframework
48             eval { ... }
49             if (my $e = HTTP::Exception::301->caught) {
50             my $self->req->redirect($e->location);
51             }
52              
53             =head1 DESCRIPTION
54              
55             This package is the base class for all 3XX (redirect) Exceptions.
56             This makes adding features for a range of exceptions easier.
57              
58             DON'T USE THIS PACKAGE DIRECTLY. 'use HTTP::Exception' does this for you.
59              
60             =head1 ADDITIONAL FIELDS
61              
62             Fields, that 3XX-Exceptions provide over HTTP::Exceptions.
63              
64             =head2 location
65              
66             Indicates, where the browser is being redirected to.
67              
68             =head1 AUTHOR
69              
70             Thomas Mueller, C<< >>
71              
72             =head1 BUGS
73              
74             Please report any bugs or feature requests to
75             C, or through the web interface at
76             L.
77             I will be notified, and then you'll automatically be notified of progress on
78             your bug as I make changes.
79              
80             =head1 SUPPORT
81              
82             You can find documentation for this module with the perldoc command.
83              
84             perldoc HTTP::Exception::Base
85              
86             You can also look for information at:
87              
88             =over 4
89              
90             =item * RT: CPAN's request tracker
91              
92             L
93              
94             =item * AnnoCPAN: Annotated CPAN documentation
95              
96             L
97              
98             =item * CPAN Ratings
99              
100             L
101              
102             =item * Search CPAN
103              
104             L
105              
106             =back
107              
108             =head1 LICENSE AND COPYRIGHT
109              
110             Copyright 2010 Thomas Mueller.
111              
112             This program is free software; you can redistribute it and/or modify it
113             under the terms of either: the GNU General Public License as published
114             by the Free Software Foundation; or the Artistic License.
115              
116             See http://dev.perl.org/licenses/ for more information.
117              
118              
119             =cut