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;
2             our $AUTHORITY = 'cpan:STEVAN';
3             $HTTP::Throwable::Role::Status::ProxyAuthenticationRequired::VERSION = '0.026';
4 1     1   922 use Types::Standard qw(Str ArrayRef);
  1         2  
  1         11  
5              
6 1     1   681 use Moo::Role;
  1         2  
  1         9  
7              
8             with(
9             'HTTP::Throwable',
10             'HTTP::Throwable::Role::BoringText',
11             );
12              
13 4     4 0 159 sub default_status_code { 407 }
14 4     4 0 16774 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   514 no Moo::Role; 1;
  1         2  
  1         4  
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.026
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 ATTRIBUTES
59              
60             =head2 proxy_authenticate
61              
62             This is a required string or array of strings that will be used to populate
63             the 'Proxy-Authenticate' header(s) when creating a PSGI response.
64              
65             =head1 SEE ALSO
66              
67             HTTP Authentication: Basic and Digest Access Authentication - L
68              
69             Proxy-Authenticate Header - L
70              
71             =head1 AUTHORS
72              
73             =over 4
74              
75             =item *
76              
77             Stevan Little
78              
79             =item *
80              
81             Ricardo Signes
82              
83             =back
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2011 by Infinity Interactive, Inc..
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut
93              
94             __END__