aboutsummaryrefslogtreecommitdiff
path: root/www/p5-CGI-Cookie-XS/pkg-PM
blob: 10ba43b6919c6793585abb5a1570a70df5c6db7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
=head1 NAME

Cookie::XS - HTTP Cookie parser in C

=head1 VERSION

This document describes Cookie::XS 0.09 released on March 24, 2008.

=head1 DESCRIPTION

This module implements a very simple parser for cookies used in HTTP applications. We've found L<CGI::Simple::Cookie> and L<CGI::Cookie> rather slow according to the profiling results for our L<OpenResty> project, hence the rewrite in C.

This library is still in B<pre-alpha> stage and the API is still in flux. We're just following the "release early, releaes often" guideline. So please check back often ;)

=head1 METHODS

We currently provide 2 static methods, C<parse> and C<fetch>. They work mostly the same way as those methods found in L<CGI::Cookie> and L<CGI::Simple::Cookie> but with the exception that our version returns plain Perl data structures rather than hashes of Perl objects (due to performance considerations).

We'll implement some cookie dump methods in the near future.

=over

=item C<< $ref = Cookie::XS->parse($raw_cookie) >>

Parses C<$raw_cookie> and returns the reference of a hash of arrays. The keys
of the hash are cookie variables' names while the values of the hash are lists of cookie variable's values.

There is a length limit on the C<$raw_cookie>. If C<$raw_cookie> is longer than 4 KB (i.e. 4 * 1024 bytes, excluding the trailing '\0'), the overflowing part will be truncated.

Also note that, C<fetch> does not assume any encoding on the cookie values. It just decodes the encoded entries verbatim and treat them as plain "binary" stuff.

=item C<< $ref = Cookie::XS->fetch() >>

Reads the raw cookie from the C<HTTP_COOKIE> and C<COOKIE> environments
(which are usually set by HTTP servers like lighttd or apache) and then
parses the value using the C<parse> method and finally returns the
results.

=back

=head1 TODO

=over

=item *

Removing trailing spaces in cookie values.

=back

=head1 SOURCE CONTROL

For the very latest version of this module, check out the source from
the SVN repos below:

L<http://svn.openfoundry.org/cookieparser>

There is anonymous access to all. If you'd like a commit bit, please let
us know. :)

=head1 BUGS

There must be some serious bugs lurking somewhere. We haven't done comprehensive testing for our code yet. It's a TODO.

Please report bugs or send wish-list to
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Cookie-XS>.

=head1 SEE ALSO

L<CGI::Cookie>, L<CGI::Cookie::Simple>.

=head1 AUTHOR

=over

=item yuting C<< <yuting at alibaba-inc.com> >>

=item agentzh C<< <agentzh at yahoo.cn> >>

=back

=head1 COPYRIGHT

Copyright (c) 2008 by Yahoo! China EEEE Works, Alibaba Inc.

=head1 License

The "MIT" License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.