line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/KeepAlive.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::KeepAlive; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
3
|
|
|
3
|
|
4569
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
92
|
|
18
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
19
|
3
|
|
|
3
|
|
18
|
use warnings::register; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
386
|
|
20
|
3
|
|
|
3
|
|
20
|
use parent qw( HTTP::Promise::Headers::Generic ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
18
|
|
21
|
3
|
|
|
3
|
|
239
|
our $VERSION = 'v0.1.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
50
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
60
|
|
25
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
1107
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
1
|
3699
|
my $self = shift( @_ ); |
30
|
3
|
|
|
|
|
303
|
$self->{params} = []; |
31
|
3
|
|
|
|
|
17
|
$self->{properties} = {}; |
32
|
|
|
|
|
|
|
# Works like HTTP::Promise::Headers::CacheControl |
33
|
3
|
50
|
66
|
|
|
41
|
@_ = () if( @_ == 1 && $self->_is_a( $_[0] => 'Module::Generic::Null' ) ); |
34
|
3
|
100
|
|
|
|
75
|
if( @_ ) |
35
|
|
|
|
|
|
|
{ |
36
|
2
|
|
|
|
|
10
|
my $this = shift( @_ ); |
37
|
2
|
50
|
|
|
|
17
|
my $ref = $self->_is_array( $this ) ? $this : [split( /[[:blank:]\h]*\,[[:blank:]\h]*/, "$this" )]; |
38
|
2
|
|
|
|
|
63
|
my $params = $self->params; |
39
|
2
|
|
|
|
|
1585
|
my $props = $self->properties; |
40
|
2
|
|
|
|
|
2484
|
foreach my $pair ( @$ref ) |
41
|
|
|
|
|
|
|
{ |
42
|
4
|
|
|
|
|
34
|
my( $prop, $val ) = split( /=/, $pair, 2 ); |
43
|
4
|
|
|
|
|
20
|
$props->{ $prop } = $val; |
44
|
4
|
|
|
|
|
134
|
$params->push( $prop ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
3
|
|
|
|
|
31
|
$self->{_init_strict_use_sub} = 1; |
48
|
3
|
50
|
|
|
|
20
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
49
|
3
|
|
|
|
|
22
|
$self->_field_name( 'Forwarded' ); |
50
|
3
|
|
|
|
|
2351
|
return( $self ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
3
|
1
|
596
|
sub as_string { return( shift->_set_get_properties_as_string ); } |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
3
|
1
|
489
|
sub max { return( shift->_set_get_property_number( 'max', @_ ) ); } |
56
|
|
|
|
|
|
|
|
57
|
11
|
|
|
11
|
1
|
45
|
sub params { return( shift->_set_get_array_as_object( 'params', @_ ) ); } |
58
|
|
|
|
|
|
|
|
59
|
11
|
|
|
11
|
1
|
42
|
sub properties { return( shift->_set_get_hash_as_mix_object( 'properties', @_ ) ); } |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
3
|
1
|
552
|
sub timeout { return( shift->_set_get_property_number( 'timeout', @_ ) ); } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
# NOTE: POD |
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding utf-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
HTTP::Promise::Headers::KeepAlive - Keep Alive Header Field |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use HTTP::Promise::Headers::KeepAlive; |
76
|
|
|
|
|
|
|
my $keep = HTTP::Promise::Headers::KeepAlive->new || |
77
|
|
|
|
|
|
|
die( HTTP::Promise::Headers::KeepAlive->error, "\n" ); |
78
|
|
|
|
|
|
|
$keep->max(1000); |
79
|
|
|
|
|
|
|
$keep->timeout(10); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
v0.1.0 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The following is an extract from Mozilla documentation. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The Keep-Alive general header allows the sender to hint about how the connection may be used to set a timeout and a maximum amount of requests. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
For example response containing a Keep-Alive header: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
HTTP/1.1 200 OK |
94
|
|
|
|
|
|
|
Connection: Keep-Alive |
95
|
|
|
|
|
|
|
Content-Encoding: gzip |
96
|
|
|
|
|
|
|
Content-Type: text/html; charset=utf-8 |
97
|
|
|
|
|
|
|
Date: Thu, 11 Aug 2016 15:23:13 GMT |
98
|
|
|
|
|
|
|
Keep-Alive: timeout=5, max=1000 |
99
|
|
|
|
|
|
|
Last-Modified: Mon, 25 Jul 2016 04:32:39 GMT |
100
|
|
|
|
|
|
|
Server: Apache |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 METHODS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 as_string |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a string representation of the C<Keep-Alive> object. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 max |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
An integer that is the maximum number of requests that can be sent on this connection before closing it. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 params |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns the L<array object|Module::Generic::Array> used by this header field object containing all the properties set. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 properties |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the L<hash object|Module::Generic::hash> used as a repository of properties. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 timeout |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
An integer that is the time in seconds that the host will allow an idle connection to remain open before it is closed. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SEE ALSO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
See also L<rfc7230, section A.1.2|https://tools.ietf.org/html/rfc7230#section-A.1.2> and L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
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> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Copyright(c) 2022 DEGUEST Pte. Ltd. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
All rights reserved. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |