lib/HTTP/Promise/Headers/ClearSiteData.pm

filter: Statementstmt 100% 40 / 40 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 15 / 15 Podpod 100% 9 / 9 totaltotal 91.1% 72 / 79 CC 7 SCAR 9.5
CC
7
Cov
91%
init
6.2
as_string
2.0
BEGIN
1.0
CRAP 2.6
« lib/HTTP/Promise/Headers/CacheControl.pm ↑ Summary blib/lib/HTTP/Promise/Exception.pm »
1 ##----------------------------------------------------------------------------
2 ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/ClearSiteData.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::ClearSiteData;
15 BEGIN
16 {
17 3 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶ warnings::register_categories( 'HTTP::Promise' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶ use parent qw( HTTP::Promise::Headers::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 our $VERSION = 'v0.1.0';
22 };
23  
24 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 sub init
28 {
29 4 ▶ my $self = shift( @_ );
Subroutine init: called CC=6 SCAR=18.2
Pod documented
30 4 $self->{params} = [];
31 4 $self->{properties} = {};
32 4 ▶ @_ = () if( @_ == 1 && $self->_is_a( $_[0] => 'Module::Generic::Null' ) );
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and $self->_is_a($_[0], "Module::Generic::Null") 0 4 4
Condition66%2/3
@_ == 1 and $self->_is_a($_[0], "Module::Generic::Null")
!ll&&!rl&&r
130
MC/DC0%0/2
@_ == 1 and $self->_is_a($_[0], "Module::Generic::Null")
@_ == 1 $self->_is_a($_[0], "Module::Generic::Null")
Truth table66%2/3
A and B
A= @_ == 1B= $self->_is_a($_[0], "Module::Generic::Null")
ABresult
0X0
100
111
33 4 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 1 4
34 {
35 3 my $this = shift( @_ );
36 3 ▶ my $ref = $self->new_array( $self->_is_array( $this ) ? $this : [$self->_qstring_split( "$this" )] );
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_array($this) ? : 0 3 3
37 3 $self->params( $ref );
38 }
39 4 $self->{_init_strict_use_sub} = 1;
40 4 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 4 4
41 4 $self->_field_name( 'Clear-Site-Data' );
42 4 return( $self );
43 }
44  
45 sub as_string
46 {
47 8 ▶ my $self = shift( @_ );
Subroutine as_string: called CC=2 SCAR=7.1
Pod documented
48 8 my $params = $self->params;
49 8 ▶ return( $params->is_empty ? '' : $self->_qstring_join( @$params ) );
Branch: 1 branch
BranchTrueFalseTotal
$params->is_empty ? : 0 8 8
50 }
51  
52 6 ▶sub cache { return( shift->_set_get_property_boolean( 'cache', @_ ) ); }
Subroutine cache: called CC=1 SCAR=0.0
Pod documented
53  
54 4 ▶sub cookies { return( shift->_set_get_property_boolean( 'cookies', @_ ) ); }
Subroutine cookies: called CC=1 SCAR=0.0
Pod documented
55  
56 4 ▶sub execution_contexts { return( shift->_set_get_property_boolean( 'executionContexts', @_ ) ); }
Subroutine execution_contexts: called CC=1 SCAR=0.0
Pod documented
57  
58 30 ▶sub params { return( shift->_set_get_array_as_object( 'params', @_ ) ); }
Subroutine params: called CC=1 SCAR=0.0
Pod documented
59  
60 19 ▶sub properties { return( shift->_set_get_hash_as_mix_object( 'properties', @_ ) ); }
Subroutine properties: called CC=1 SCAR=0.0
Pod documented
61  
62 4 ▶sub storage { return( shift->_set_get_property_boolean( 'storage', @_ ) ); }
Subroutine storage: called CC=1 SCAR=0.0
Pod documented
63  
64 1 ▶sub wildcard { return( shift->_set_get_property_boolean( '*', @_ ) ); }
Subroutine wildcard: called CC=1 SCAR=0.0
Pod documented
65  
66 3 1;
67 # NOTE: POD
68 __END__
69  
70 =encoding utf-8
71  
72 =head1 NAME
73  
74 HTTP::Promise::Headers::ClearSiteData - Clear-Site-Data Header Field
75  
76 =head1 SYNOPSIS
77  
78 use HTTP::Promise::Headers::ClearSiteData;
79 my $csd = HTTP::Promise::Headers::ClearSiteData->new ||
80 die( HTTP::Promise::Headers::ClearSiteData->error, "\n" );
81 my $h = HTTP::Promise::Headers::ClearSiteData->new;
82 # Single directive
83 # Clear-Site-Data: "cache"
84 $h->cache(1);
85  
86 # Multiple directives (comma separated)
87 # Clear-Site-Data: "cache", "cookies"
88 $h->cache(1);
89 $h->cookies(1);
90  
91 # Wild card
92 # Clear-Site-Data: "*"
93 $h->params('*');
94  
95 =head1 VERSION
96  
97 v0.1.0
98  
99 =head1 DESCRIPTION
100  
101 The following is an extract from Mozilla documentation.
102  
103 The C<Clear-Site-Data> header clears browsing data (cookies, storage, cache) associated with the requesting website. It allows web developers to have more control over the data stored by a client browser for their origins.
104  
105 Example:
106  
107 Clear-Site-Data: "cache", "cookies", "storage", "executionContexts"
108  
109 =head1 METHODS
110  
111 =head2 cache
112  
113 Sets or gets the property C<cache>
114  
115 Indicates that the server wishes to remove locally cached data (the browser cache, see HTTP caching) for the origin of the response URL. Depending on the browser, this might also clear out things like pre-rendered pages, script caches, WebGL shader caches, or address bar suggestions.
116  
117 =head2 cookies
118  
119 Sets or gets the property C<cookies>
120  
121 Indicates that the server wishes to remove all cookies for the origin of the response URL. HTTP authentication credentials are also cleared out. This affects the entire registered domain, including subdomains. So https://example.com as well as https://stage.example.com, will have cookies cleared.
122  
123 =head2 execution_contexts
124  
125 Sets or gets the property C<executionContexts>
126  
127 Indicates that the server wishes to reload all browsing contexts for the origin of the response (Location.reload).
128  
129 =head2 params
130  
131 Returns the L<array object|Module::Generic::Array> used by this header field object containing all the properties set.
132  
133 =head2 properties
134  
135 Returns the L<hash object|Module::Generic::hash> used as a repository of properties.
136  
137 =head2 storage
138  
139 Sets or gets the property C<storage>
140  
141 Indicates that the server wishes to remove all DOM storage for the origin of the response URL.
142  
143 =head2 wildcard
144  
145 Sets or gets the special property C<*> (wildcard)
146  
147 Indicates that the server wishes to clear all types of data for the origin of the response. If more data types are added in future versions of this header, they will also be covered by it.
148  
149 =head1 THREAD-SAFETY
150  
151 This module is thread-safe for all operations, as it operates on per-object state and uses thread-safe external libraries.
152  
153 =head1 AUTHOR
154  
155 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
156  
157 =head1 SEE ALSO
158  
159 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data>
160  
161 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>
162  
163 =head1 COPYRIGHT & LICENSE
164  
165 Copyright(c) 2022 DEGUEST Pte. Ltd.
166  
167 All rights reserved.
168  
169 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
170  
171 =cut
« lib/HTTP/Promise/Headers/CacheControl.pm ↑ Summary blib/lib/HTTP/Promise/Exception.pm »