File Coverage

blib/lib/HTTP/Throwable/Role/Status/ProxyAuthenticationRequired.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 16 18 88.8


line stmt bran cond sub pod time code
1             package HTTP::Throwable::Role::Status::ProxyAuthenticationRequired 0.028;
2             our $AUTHORITY = 'cpan:STEVAN';
3              
4 1     1   705 use Types::Standard qw(Str ArrayRef);
  1         2  
  1         12  
5              
6 1     1   754 use Moo::Role;
  1         3  
  1         10  
7              
8             with(
9             'HTTP::Throwable',
10             'HTTP::Throwable::Role::BoringText',
11             );
12              
13 4     4 0 204 sub default_status_code { 407 }
14 4     4 0 19361 sub default_reason { 'Proxy Authentication Required' }
15              
16             has 'proxy_authenticate' => (
17             is => 'ro',
18             isa => Str | ArrayRef[ Str ],
19             required => 1,
20             );
21              
22             around 'build_headers' => sub {
23             my $next = shift;
24             my $self = shift;
25             my $headers = $self->$next( @_ );
26             my $proxy_auth = $self->proxy_authenticate;
27             if ( ref $proxy_auth ) {
28             push @$headers => (map { ('Proxy-Authenticate' => $_) } @$proxy_auth);
29             }
30             else {
31             push @$headers => ('Proxy-Authenticate' => $proxy_auth );
32             }
33             $headers;
34             };
35              
36 1     1   553 no Moo::Role; 1;
  1         2  
  1         7  
37              
38             =pod
39              
40             =encoding UTF-8
41              
42             =head1 NAME
43              
44             HTTP::Throwable::Role::Status::ProxyAuthenticationRequired - 407 Proxy Authentication Required
45              
46             =head1 VERSION
47              
48             version 0.028
49              
50             =head1 DESCRIPTION
51              
52             This code is similar to 401 (Unauthorized), but indicates that the
53             client must first authenticate itself with the proxy. The proxy MUST
54             return a Proxy-Authenticate header field containing a challenge applicable
55             to the proxy for the requested resource. The client MAY repeat the request
56             with a suitable Proxy-Authorization header field.
57              
58             =head1 PERL VERSION
59              
60             This library should run on perls released even a long time ago. It should work
61             on any version of perl released in the last five years.
62              
63             Although it may work on older versions of perl, no guarantee is made that the
64             minimum required version will not be increased. The version may be increased
65             for any reason, and there is no promise that patches will be accepted to lower
66             the minimum required perl.
67              
68             =head1 ATTRIBUTES
69              
70             =head2 proxy_authenticate
71              
72             This is a required string or array of strings that will be used to populate
73             the 'Proxy-Authenticate' header(s) when creating a PSGI response.
74              
75             =head1 SEE ALSO
76              
77             HTTP Authentication: Basic and Digest Access Authentication - L
78              
79             Proxy-Authenticate Header - L
80              
81             =head1 AUTHORS
82              
83             =over 4
84              
85             =item *
86              
87             Stevan Little
88              
89             =item *
90              
91             Ricardo Signes
92              
93             =back
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             This software is copyright (c) 2011 by Infinity Interactive, Inc.
98              
99             This is free software; you can redistribute it and/or modify it under
100             the same terms as the Perl 5 programming language system itself.
101              
102             =cut
103              
104             __END__