line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Cookies.pm,v 1.6 2003/07/03 15:54:00 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::Cookies; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::Cookies - Cookie storage and management |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use HTTP::WebTest::Cookies; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$cookie_jar = HTTP::WebTest::Cookies->new; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$cookie_jar->accept_cookies($bool); |
16
|
|
|
|
|
|
|
$cookie_jar->send_cookies($bool); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$cookie_jar->add_cookie_header($request); |
19
|
|
|
|
|
|
|
$cookie_jar->extract_cookies($response); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Subclass of L which enables optional |
24
|
|
|
|
|
|
|
transmission and receipt of cookies. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
20
|
|
|
20
|
|
134
|
use strict; |
|
20
|
|
|
|
|
38
|
|
|
20
|
|
|
|
|
988
|
|
31
|
|
|
|
|
|
|
|
32
|
20
|
|
|
20
|
|
122
|
use base qw(HTTP::Cookies); |
|
20
|
|
|
|
|
42
|
|
|
20
|
|
|
|
|
26928
|
|
33
|
|
|
|
|
|
|
|
34
|
20
|
|
|
20
|
|
260514
|
use HTTP::WebTest::Utils qw(make_access_method); |
|
20
|
|
|
|
|
82
|
|
|
20
|
|
|
|
|
4816
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 accept_cookies($optional_accept_cookies) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Returns the current setting of accept_cookies. |
39
|
|
|
|
|
|
|
If optional boolean parameter C<$optional_accept_cookies> is passed, |
40
|
|
|
|
|
|
|
enables or disables receipt of cookies. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 Returns |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
True if receipt of cookies is enabled; false otherwise. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
*accept_cookies = make_access_method('ACCEPT_COOKIES'); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 send_cookies($optional_send_cookies) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns the current setting of send_cookies. |
53
|
|
|
|
|
|
|
If optional boolean parameter C<$optional_send_cookies> is passed, |
54
|
|
|
|
|
|
|
enables or disables transmission of cookies. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 Returns |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
True if transmission of cookies is enabled; false otherwise. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
*send_cookies = make_access_method('SEND_COOKIES'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 extract_cookies (...) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Overloaded method. If receipt of cookies is enabled, passes all arguments |
67
|
|
|
|
|
|
|
to C. Otherwise, does nothing. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub extract_cookies { |
72
|
196
|
|
|
196
|
1
|
23122535
|
my $self = shift; |
73
|
196
|
100
|
|
|
|
1471
|
$self->SUPER::extract_cookies(@_) if $self->accept_cookies; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 add_cookie_header (...) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Overloaded method. If transmission of cookies is enabled, |
79
|
|
|
|
|
|
|
passes all arguments to C. Otherwise, does nothing. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub add_cookie_header { |
84
|
196
|
|
|
196
|
1
|
94732
|
my $self = shift; |
85
|
196
|
100
|
|
|
|
1115
|
$self->SUPER::add_cookie_header(@_) if $self->send_cookies; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright (c) 2000-2001 Richard Anderson. All rights reserved. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
95
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |