File Coverage

lib/HTTP/Promise/Headers/ContentSecurityPolicyReportOnly.pm
Criterion Covered Total %
statement 24 24 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 36 37 97.3


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/ContentSecurityPolicyReportOnly.pm
3             ## Version v0.1.0
4             ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2022/05/07
7             ## Modified 2022/05/07
8             ## All rights reserved.
9             ##
10             ##
11             ## This program is free software; you can redistribute it and/or modify it
12             ## under the same terms as Perl itself.
13             ##----------------------------------------------------------------------------
14             package HTTP::Promise::Headers::ContentSecurityPolicyReportOnly;
15             BEGIN
16             {
17 3     3   2146 use strict;
  3         8  
  3         100  
18 3     3   17 use warnings;
  3         6  
  3         89  
19 3     3   17 use warnings::register;
  3         7  
  3         474  
20 3     3   20 use parent qw( HTTP::Promise::Headers::ContentSecurityPolicy );
  3         8  
  3         32  
21 3     3   319 our $VERSION = 'v0.1.0';
22             };
23              
24 3     3   19 use strict;
  3         10  
  3         61  
25 3     3   15 use warnings;
  3         13  
  3         373  
26              
27             sub init
28             {
29 2     2 1 795 my $self = shift( @_ );
30 2 50       25 $self->SUPER::init( @_ ) || return( $self->pass_error );
31 2         24 $self->_field_name( 'Content-Security-Policy-Report-Only' );
32 2         1577 return( $self );
33             }
34              
35 2     2 1 498 sub report_uri { return( shift->_set_get_property_value( 'report-uri', @_ ) ); }
36              
37             1;
38             # NOTE: POD
39             __END__
40              
41             =encoding utf-8
42              
43             =head1 NAME
44              
45             HTTP::Promise::Headers::ContentSecurityPolicyReportOnly - Content-Security-Policy-Report-Only Header Field
46              
47             =head1 SYNOPSIS
48              
49             use HTTP::Promise::Headers::ContentSecurityPolicyReportOnly;
50             my $this = HTTP::Promise::Headers::ContentSecurityPolicyReportOnly->new || die( HTTP::Promise::Headers::ContentSecurityPolicyReportOnly->error, "\n" );
51              
52             =head1 VERSION
53              
54             v0.1.0
55              
56             =head1 DESCRIPTION
57              
58             The following description is taken from Mozilla documentation.
59              
60             This class inherits all the method from L<HTTP::Promise::Headers::ContentSecurityPolicy> and implements the additional following ones.
61              
62             The CSP L</report_uri> method should be used with this header, otherwise this class will be an expensive no-op interface.
63              
64             Content-Security-Policy-Report-Only: default-src https:; report-uri /csp-violation-report-endpoint/
65              
66             =head1 METHODS
67              
68             =head2 report_uri
69              
70             This takes an uri where the report will be sent. See L<this Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri> for an example php script to use to get those reports.
71              
72             =head1 AUTHOR
73              
74             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
75              
76             =head1 SEE ALSO
77              
78             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only> and also L<this documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri>
79              
80             L<HTTP::Promise>, L<HTTP::Promise::Request>, L<HTTP::Promise::Response>, L<HTTP::Promise::Message>, L<HTTP::Promise::Entity>, L<HTTP::Promise::Headers>, L<HTTP::Promise::Body>, L<HTTP::Promise::Body::Form>, L<HTTP::Promise::Body::Form::Data>, L<HTTP::Promise::Body::Form::Field>, L<HTTP::Promise::Status>, L<HTTP::Promise::MIME>, L<HTTP::Promise::Parser>, L<HTTP::Promise::IO>, L<HTTP::Promise::Stream>, L<HTTP::Promise::Exception>
81              
82             =head1 COPYRIGHT & LICENSE
83              
84             Copyright(c) 2022 DEGUEST Pte. Ltd.
85              
86             All rights reserved.
87              
88             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
89              
90             =cut