Commit af4d988f authored by Jacques's avatar Jacques
Browse files

Release of version v0.1.1

parent 64f2ae56
......@@ -631,7 +631,7 @@ sub fetch
my @all = $o->jar;
foreach my $cookie_name ( @all )
{
my @values = $o->get( $cookie_name );
my @values = $o->jar( $cookie_name );
foreach my $v ( @values )
{
# And of course, Apache/modperl does not uri decode the cookie value...
......@@ -640,7 +640,7 @@ sub fetch
push( @$cookies, $c );
}
}
$self->messagef( 3, "%d cookies found using APR::Request::Apache2.", scalar( keys( %$cookies ) ) );
$self->messagef( 3, "%d cookies found using APR::Request::Apache2.", scalar( @$cookies ) );
}
else
{
......@@ -649,7 +649,7 @@ sub fetch
}
catch( $e )
{
$self->message( 3, "An error occurred while trying to get cookies using APR::Request::Apache2, reverting to Cookie header" );
$self->message( 3, "An error occurred while trying to get cookies using APR::Request::Apache2, reverting to Cookie header: $e" );
}
$cookie_header = $r->headers_in->get( 'Cookie' );
}
......@@ -1533,7 +1533,9 @@ Cookies - Cookies API for Server & Client
}
# get the cookie
my $sid = $jar->get( 'my-cookie' );
# set a new cookie
# get all cookies
my @all = $jar->get( 'my-cookie', 'example.com', '/' );
# set a new Set-Cookie header
$jar->set( 'my-cookie' => $cookie_object );
# Remove cookie from jar
$jar->delete( 'my-cookie' );
......@@ -1551,7 +1553,7 @@ Cookies - Cookies API for Server & Client
# or add an existing cookie
$jar->add( $some_cookie_object );
return( $jar->make({
my $c = $jar->make({
name => 'my-cookie',
domain => 'example.com',
value => 'sid1234567',
......@@ -1563,7 +1565,7 @@ Cookies - Cookies API for Server & Client
http_only => 1,
# should it be used under ssl only?
secure => 1,
}) );
});
# Add the Set-Cookie headers
$jar->add_response_header;
......@@ -1696,6 +1698,8 @@ As long as the object provided supports the C<uri> and C<header> method, you can
Please refer to the L<rfc6265|https://datatracker.ietf.org/doc/html/rfc6265> for more information on the applicable rule when adding cookies to the outgoing request header.
Basically, it will add, for a given domain, first all cookies whose path is longest and at path equivalent, the cookie creation date is used, with the earliest first. Cookies who have expired are not sent, and there can be cookies bearing the same name for the same domain in different paths.
=head2 add_response_header
# Adding cookie to the repository
......@@ -1743,18 +1747,21 @@ So you can create a repository and use it to store the cookies sent by the http
=head2 delete
Given a cookie name and an optional host or a L<Cookie> object, and this will remove it from the cookie repository.
Given a cookie name, an optional host and optional path or a L<Cookie> object, and this will remove it from the cookie repository.
It returns an L<array object|Module::Generic::Array> upon success, or L<perlfunc/undef> and sets an L<error|Module::Generic/error>. Note that the array object may be empty.
However, this will NOT remove it from the web browser by sending a Set-Cookie header. For that, you might want to look at the L<Cookie/elapse> method.
It returns the cookie object removed.
It returns an L<array object|Module::Generic::Array> of cookie objects removed.
my $c = $jar->delete( 'my-cookie' );
my $arr = $jar->delete( 'my-cookie' );
# alternatively
my $c = $jar->delete( 'my-cookie' => 'www.example.org' );
my $arr = $jar->delete( 'my-cookie' => 'www.example.org' );
# or
my $c = $jar->delete( $my_cookie_object );
print( "Cookie value removed was: ", $c->value, "\n" );
my $arr = $jar->delete( $my_cookie_object );
printf( "%d cookie(s) removed.\n", $arr->length );
print( "Cookie value removed was: ", $arr->first->value, "\n" );
If you are interested in telling the http client to remove all your cookies, you can set the C<Clear-Site-Data> header:
......@@ -1795,7 +1802,7 @@ It returns 1 if it does, or 0 if it does not.
Provided with a response object, such as, but not limited to L<HTTP::Response>, and this will retrieve any cookie sent from the remote server, parse them and add their respective to the repository.
As per the L<rfc6265 specifications|https://datatracker.ietf.org/doc/html/rfc6265> if there are duplicate cookies for the same domain, only the last one will be retained.
As per the L<rfc6265, section 5.3.11 specifications|https://datatracker.ietf.org/doc/html/rfc6265#section-5.3> if there are duplicate cookies for the same domain and path, only the last one will be retained.
If the cookie received does not contain any C<Domain> specification, then, in line with rfc6265 specifications, it will take the root of the current domain as the default domain value. Since finding out what is the root for a domain name is a non-trivial exercise, this method relies on L<Cookies::Domain>.
......@@ -1835,9 +1842,9 @@ Given a cookie name, an optional host and an optional path, this will retrieve i
If not found, it will try to return a value with just the cookie name.
If nothing is found, this will return and empty list in list context or C<undef> in scalar context, so do not try to check for error if C<undef> is returned.
If nothing is found, this will return and empty list in list context or C<undef> in scalar context.
This method cannot produce an error, thus if nothing is found, it is guaranteed to mean the cookie does not exist.
You can C<get> multiple cookies and this method will return a list in list context and the first cookie found in scalar context.
# Wrong, an undefined returned value here only means there is no such cookie
my $c = $jar->get( 'my-cookie' );
......@@ -2050,7 +2057,7 @@ This returns an L<array object|Module::Generic::Array> of all the cookies thus r
=head2 repo
Set or get the L<hash object|Module::Generic::Hash> used as the cookie jar repository.
Set or get the L<array object|Module::Generic::Array> used as the cookie jar repository.
printf( "%d cookies found\n", $jar->repo->length );
......@@ -2244,6 +2251,8 @@ L<Apache2::Cookies>, L<APR::Request::Cookie>, L<Cookie::Baker>
L<Latest tentative version of the cookie standard|https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-09>
L<Mozilla documentation on Set-Cookie|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie>
L<Information on double submit cookies|https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie>
=head1 COPYRIGHT & LICENSE
......
......@@ -141,7 +141,7 @@ sub cron_fetch
{
my $resp = $ua->get( URL, %$req_headers );
$self->message( 3, "Initial query was: ", $resp->request->as_string );
$self->message( 3, "Server response is: ", $resp->as_string );
$self->message( 3, "Server response is: ", $resp->headers->as_string );
my $code = $resp->code;
my $data = $resp->decoded_content( default_charset => 'utf-8', alt_charset => 'utf-8' );
$self->message( 3, "Server responded with code $code and ", length( $data ), " bytes of data." );
......@@ -158,9 +158,11 @@ sub cron_fetch
my $epoch = $last_mod->epoch;
if( $resp->header( 'etag' ) )
{
$dont_have_etag = $resp->header( 'etag' ) eq $meta->{etag} ? 0 : 1;
$meta->{etag} = $resp->header( 'etag' );
$meta->{etag} =~ s/^\"([^"]+)\"$/$1/;
}
if( $code == 304 ||
( !$file->is_empty && $mtime && $mtime == $epoch ) )
{
......@@ -185,7 +187,9 @@ sub cron_fetch
return( $self->error( "Remote server returned no data." ) );
}
$self->message( 3, "Saving ", length( $data ), " bytes of data to file \"$file\"." );
$file->lock;
$file->unload_utf8( $data ) || return( $self->error( "Unable to open public suffix data file \"$file\" in write mode: ", $file->error ) );
$file->unlock;
$file->utime( $epoch, $epoch );
$self->load_public_suffix || return( $self->pass_error );
$self->save_as_json || return( $self->pass_error );
......
......@@ -7132,7 +7132,7 @@ org.zw
// newGTLDs
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2021-10-28T15:13:35Z
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2021-11-13T15:12:42Z
// This list is auto-generated, don't edit it manually.
// aaa : 2015-02-26 American Automobile Association, Inc.
aaa
......@@ -7647,7 +7647,7 @@ cars
// casa : 2013-11-21 Registry Services, LLC
casa
// case : 2015-09-03 CNH Industrial N.V.
// case : 2015-09-03 Helium TLDs Ltd
case
// cash : 2014-03-06 Binky Moon, LLC
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment