Hi :) libwww is great library, I'd say.
Just one note: it acn read cookies only from file.
So if one wants to store cookies in DB, he needs to parse
output of $cookie_jar->as_string() at some point.
But this work is done perfectly in the load() function!
So I offer to redesign load() in the following way
1. read and verify the magic header
2. real all other lines (as single string)
3. invoke some new function (say, from_string()) to parse the read
string.
This way, one can store cookies data in any way he wants,
then load them, and then easily initialize the cookies_jar
with one-step function from_string().
I updated file Cookies.pp to accomodate this.
Here are the diffs, and attached is the entire file:
diff -b /usr/local/lib/perl5/site_perl/5.8.0/HTTP/Cookies.pm my_Cookies.pm
528a529,531
>
> my @lines;
>
530c533
< unless ($magic =~ /^\#LWP-Cookies-(\d+\.\d+)/) {
---
> unless ( $magic =~ /^\#LWP-Cookies-(\d+\.\d+)/ ) {
533a537
>
535,536c539,560
< next unless s/^Set-Cookie3:\s*//;
< chomp;
---
> my $line = $_;
> next unless $line =~ s/^Set-Cookie3:\s*//;
> chomp $line;
> push @lines, $line;
> }
> close(FILE);
>
> $self->{from_string} = join( "\n", @lines );
>
> $self->from_string;
> 1;
> }
>
> sub from_string
> {
> my $self = shift;
> my $string = shift || $self->{from_string} || return;
>
> foreach my $line ( split( /\n/, $string ) ) {
>
> $line =~ s/^Set-Cookie3:\s*//;
>
538c562,563
< for $cookie (split_header_words($_)) {
---
>
> for $cookie ( split_header_words($line) ) {
562,563d586
< close(FILE);
< 1;
cookies.pm
Description: Binary data
