blib/lib/Net/API/REST/Cookies.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## REST API Framework - ~/lib/Net/API/REST/Cookies.pm
4 ## Version v1.0.0
5 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
6 ## Author: Jacques Deguest <jack@deguest.jp>
7 ## Created 2019/10/08
8 ## Modified 2023/06/10
9 ## All rights reserved
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 Net::API::REST::Cookies;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 use parent qw( Cookie::Jar );
20 use vars qw( $VERSION );
21 our $VERSION = 'v1.0.0';
22 };
23  
24 use strict;
25 use warnings;
26  
27 1;
28 # NOTE: pod
29 __END__
30  
31 =encoding utf8
32  
33 =head1 NAME
34  
35 Net::API::REST::Cookies - Cookie Jar and cookie management
36  
37 =head1 SYNOPSIS
38  
39 use Net::API::REST::Cookies;
40 my $jar = Net::API::REST::Cookies->new( request => $self, debug => $self->debug ) ||
41 return( $self->error( "An error occurred while trying to get the cookie jar." ) );
42 $jar->fetch;
43 if( $jar->exists( 'my-cookie' ) )
44 {
45 # do something
46 }
47 # get the cookie
48 my $sid = $jar->get( 'my-cookie' );
49 # set a new cookie
50 $jar->set( 'my-cookie' => $cookie_object );
51 # Remove cookie from jar
52 $jar->delete( 'my-cookie' );
53  
54 return( $jar->make({
55 name => 'my-cookie',
56 domain => 'example.com',
57 value => 'sid1234567',
58 path => '/',
59 expires => '+10D',
60 ## or alternatively
61 maxage => 864000
62 ## to make it exclusively accessible by regular http request and not ajax
63 http_only => 1,
64 ## should it be used under ssl only?
65 secure => 1,
66 }) );
67  
68 =head1 VERSION
69  
70 v1.0.0
71  
72 =head1 DESCRIPTION
73  
74 This is a module to handle cookies sent from the web browser, and also to create new cookie to be returned by the server to the web browser.
75  
76 As of version C<1.0.0>, this module inherits all of its methods from L<Cookie::Jar>. Please check its documentation directly.
77  
78 The reason for this module is because Apache2::Cookie does not work well in decoding cookies, and L<Cookie::Baker> C<Set-Cookie> timestamp format is wrong. They use Mon-09-Jan 2020 12:17:30 GMT where it should be, as per rfc 6265 Mon, 09 Jan 2020 12:17:30 GMT
79  
80 Also L<APR::Request::Cookie> and L<Apache2::Cookie> which is a wrapper around L<APR::Request::Cookie> return a cookie object that returns the value of the cookie upon stringification instead of the full C<Set-Cookie> parameters. Clearly they designed it with a bias leaned toward collecting cookies from the browser.
81  
82 =head1 AUTHOR
83  
84 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
85  
86 =head1 SEE ALSO
87  
88 L<Cookie::Jar>, L<Cookie>
89  
90 =head1 COPYRIGHT & LICENSE
91  
92 Copyright (c) 2018-2023 DEGUEST Pte. Ltd.
93  
94 You can use, copy, modify and redistribute this package and associated
95 files under the same terms as Perl itself.
96  
97 =cut