line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/ExpectCT.pm |
3
|
|
|
|
|
|
|
## Version v0.1.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2022 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2022/05/08 |
7
|
|
|
|
|
|
|
## Modified 2022/05/08 |
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::ExpectCT; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
3
|
|
|
3
|
|
3407
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
97
|
|
18
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
92
|
|
19
|
3
|
|
|
3
|
|
14
|
use warnings::register; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
373
|
|
20
|
3
|
|
|
3
|
|
17
|
use parent qw( HTTP::Promise::Headers::Generic ); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
14
|
|
21
|
3
|
|
|
3
|
|
273
|
our $VERSION = 'v0.1.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
65
|
|
25
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1408
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
1
|
265047
|
my $self = shift( @_ ); |
30
|
3
|
|
|
|
|
168
|
$self->{params} = []; |
31
|
3
|
|
|
|
|
19
|
$self->{properties} = {}; |
32
|
3
|
|
|
|
|
15
|
$self->{_needs_quotes} = { 'report-uri' => 1 }; |
33
|
|
|
|
|
|
|
# Works like HTTP::Promise::Headers::CacheControl |
34
|
3
|
50
|
66
|
|
|
44
|
@_ = () if( @_ == 1 && $self->_is_a( $_[0] => 'Module::Generic::Null' ) ); |
35
|
3
|
100
|
|
|
|
67
|
if( @_ ) |
36
|
|
|
|
|
|
|
{ |
37
|
2
|
|
|
|
|
12
|
my $this = shift( @_ ); |
38
|
2
|
50
|
|
|
|
15
|
my $ref = $self->_is_array( $this ) ? $this : [split( /[[:blank:]\h]*\,[[:blank:]\h]*/, "$this" )]; |
39
|
2
|
|
|
|
|
55
|
my $params = $self->params; |
40
|
2
|
|
|
|
|
1639
|
my $props = $self->properties; |
41
|
2
|
|
|
|
|
2641
|
foreach my $pair ( @$ref ) |
42
|
|
|
|
|
|
|
{ |
43
|
6
|
|
|
|
|
47
|
my( $prop, $val ) = split( /=/, $pair, 2 ); |
44
|
6
|
100
|
|
|
|
44
|
$val =~ s/^"|(?<!\\)"$//g if( defined( $val ) ); |
45
|
6
|
|
|
|
|
26
|
$props->{ $prop } = $val; |
46
|
6
|
|
|
|
|
134
|
$params->push( $prop ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
3
|
|
|
|
|
21
|
$self->{_init_strict_use_sub} = 1; |
50
|
3
|
50
|
|
|
|
21
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
51
|
3
|
|
|
|
|
23
|
$self->_field_name( 'Expect-CT' ); |
52
|
3
|
|
|
|
|
2377
|
return( $self ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
3
|
1
|
566
|
sub as_string { return( shift->_set_get_properties_as_string ); } |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
3
|
1
|
925
|
sub enforce { return( shift->_set_get_property_boolean( 'enforce', @_ ) ); } |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
3
|
1
|
57
|
sub max_age { return( shift->_set_get_property_number( 'max-age', @_ ) ); } |
60
|
|
|
|
|
|
|
|
61
|
14
|
|
|
14
|
1
|
47
|
sub params { return( shift->_set_get_array_as_object( 'params', @_ ) ); } |
62
|
|
|
|
|
|
|
|
63
|
14
|
|
|
14
|
1
|
62
|
sub properties { return( shift->_set_get_hash_as_mix_object( 'properties', @_ ) ); } |
64
|
|
|
|
|
|
|
|
65
|
3
|
50
|
|
3
|
1
|
40
|
sub report_uri { return( shift->_set_get_property_value( 'report-uri', @_, ( @_ > 1 ? { needs_quotes => 1 } : () ) ) ); } |
66
|
|
|
|
|
|
|
|
67
|
3
|
|
|
3
|
|
17
|
sub _needs_quotes { return( shift->_set_get_hash_as_mix_object( '_needs_quotes', @_ ) ); } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
# NOTE: POD |
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding utf-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
HTTP::Promise::Headers::ExpectCT - Expect-CT Header Field |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
use HTTP::Promise::Headers::ExpectCT; |
82
|
|
|
|
|
|
|
my $expect = HTTP::Promise::Headers::ExpectCT->new || |
83
|
|
|
|
|
|
|
die( HTTP::Promise::Headers::ExpectCT->error, "\n" ); |
84
|
|
|
|
|
|
|
$h->max_age(86400); |
85
|
|
|
|
|
|
|
$h->report_uri( 'https://foo.example.com/report' ); |
86
|
|
|
|
|
|
|
$h->enforce(1); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
v0.1.0 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The following is an extract from Mozilla documentation. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The C<Expect-CT> header lets sites opt in to reporting and/or enforcement of Certificate Transparency requirements, to prevent the use of misissued certificates for that site from going unnoticed. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
For example: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Expect-CT: max-age=86400, enforce, report-uri="https://foo.example.com/report" |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 METHODS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 as_string |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a string representation of the C<Expect-CT> object. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 enforce |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is optional. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This is a boolean property and takes a true or false value. If true, the property is set, and if false it is removed. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Signals to the user agent that compliance with the Certificate Transparency policy should be enforced (rather than only reporting compliance) and that the user agent should refuse future connections that violate its Certificate Transparency policy. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 max_age |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The number of seconds after reception of the Expect-CT header field during which the user agent should regard the host of the received message as a known Expect-CT host. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 params |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the L<array object|Module::Generic::Array> used by this header field object containing all the properties set. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 properties |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns the L<hash object|Module::Generic::hash> used as a repository of properties. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 report_uri |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is optional. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This takes an URI as a value. The URI where the user agent should report C<Expect-CT> failures. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SEE ALSO |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
See also L<rfc draft|https://tools.ietf.org/html/draft-ietf-httpbis-expect-ct-08> and L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
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> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright(c) 2022 DEGUEST Pte. Ltd. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
All rights reserved. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |