| 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 | use strict; | ||
| 18 | use warnings; | ||
| 19 | warnings::register_categories( 'HTTP::Promise' ); | ||
| 20 | use parent qw( HTTP::Promise::Headers::ContentSecurityPolicy ); | ||
| 21 | our $VERSION = 'v0.1.0'; | ||
| 22 | }; | ||
| 23 | |||
| 24 | use strict; | ||
| 25 | use warnings; | ||
| 26 | |||
| 27 | sub init | ||
| 28 | { | ||
| 29 | my $self = shift( @_ ); | ||
| 30 | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||
| 31 | $self->_field_name( 'Content-Security-Policy-Report-Only' ); | ||
| 32 | return( $self ); | ||
| 33 | } | ||
| 34 | |||
| 35 | 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 THREAD-SAFETY | ||
| 73 | |||
| 74 | This module is thread-safe for all operations, as it operates on per-object state and uses thread-safe external libraries. | ||
| 75 | |||
| 76 | =head1 AUTHOR | ||
| 77 | |||
| 78 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||
| 79 | |||
| 80 | =head1 SEE ALSO | ||
| 81 | |||
| 82 | 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> | ||
| 83 | |||
| 84 | 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> | ||
| 85 | |||
| 86 | =head1 COPYRIGHT & LICENSE | ||
| 87 | |||
| 88 | Copyright(c) 2022 DEGUEST Pte. Ltd. | ||
| 89 | |||
| 90 | All rights reserved. | ||
| 91 | |||
| 92 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 93 | |||
| 94 | =cut |