copy gitweblite soruce code
|
1 |
package Mojo::Cookie::Request; |
2 |
use Mojo::Base 'Mojo::Cookie'; |
|
3 | ||
update Mojolicious to 4.57
|
4 |
use Mojo::Util qw(quote split_header); |
copy gitweblite soruce code
|
5 | |
6 |
sub parse { |
|
update Mojolicious 4.07
|
7 |
my ($self, $str) = @_; |
copy gitweblite soruce code
|
8 | |
9 |
my @cookies; |
|
update Mojolicious to 4.57
|
10 |
my @pairs = map {@$_} @{split_header(defined $str? $str: '')}; |
11 |
while (@pairs) { |
|
12 |
my ($name, $value) = (shift @pairs, shift @pairs); |
|
copy gitweblite soruce code
|
13 |
next if $name =~ /^\$/; |
update Mojolicious 4.07
|
14 |
push @cookies, $self->new(name => $name, value => defined $value ? $value : ''); |
copy gitweblite soruce code
|
15 |
} |
16 | ||
17 |
return \@cookies; |
|
18 |
} |
|
19 | ||
20 |
sub to_string { |
|
21 |
my $self = shift; |
|
update Mojolicious to 4.57
|
22 |
return '' unless length(my $name = defined $self->name ? $self->name : ''); |
copy gitweblite soruce code
|
23 |
my $value = defined $self->value ? $self->value : ''; |
update Mojolicious to 4.57
|
24 |
return join '=', $name, $value =~ /[,;" ]/ ? quote($value) : $value; |
copy gitweblite soruce code
|
25 |
} |
26 | ||
27 |
1; |
|
28 | ||
update Mojolicious to 4.57
|
29 |
=encoding utf8 |
30 | ||
copy gitweblite soruce code
|
31 |
=head1 NAME |
32 | ||
upgraded Mojolicious to v3.7...
|
33 |
Mojo::Cookie::Request - HTTP request cookie |
copy gitweblite soruce code
|
34 | |
35 |
=head1 SYNOPSIS |
|
36 | ||
37 |
use Mojo::Cookie::Request; |
|
38 | ||
39 |
my $cookie = Mojo::Cookie::Request->new; |
|
40 |
$cookie->name('foo'); |
|
41 |
$cookie->value('bar'); |
|
upgraded Mojolicious to v3.7...
|
42 |
say "$cookie"; |
copy gitweblite soruce code
|
43 | |
44 |
=head1 DESCRIPTION |
|
45 | ||
update Mojolicious 4.07
|
46 |
L<Mojo::Cookie::Request> is a container for HTTP request cookies as described |
47 |
in RFC 6265. |
|
copy gitweblite soruce code
|
48 | |
49 |
=head1 ATTRIBUTES |
|
50 | ||
51 |
L<Mojo::Cookie::Request> inherits all attributes from L<Mojo::Cookie>. |
|
52 | ||
53 |
=head1 METHODS |
|
54 | ||
55 |
L<Mojo::Cookie::Request> inherits all methods from L<Mojo::Cookie> and |
|
56 |
implements the following new ones. |
|
57 | ||
update Mojolicious and added...
|
58 |
=head2 parse |
copy gitweblite soruce code
|
59 | |
update Mojolicious 4.07
|
60 |
my $cookies = Mojo::Cookie::Request->parse('f=b; g=a'); |
copy gitweblite soruce code
|
61 | |
62 |
Parse cookies. |
|
63 | ||
update Mojolicious and added...
|
64 |
=head2 to_string |
copy gitweblite soruce code
|
65 | |
update Mojolicious 4.07
|
66 |
my $str = $cookie->to_string; |
copy gitweblite soruce code
|
67 | |
68 |
Render cookie. |
|
69 | ||
70 |
=head1 SEE ALSO |
|
71 | ||
72 |
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>. |
|
73 | ||
74 |
=cut |