The use of
HTTP::CookieJar is recommended over
HTTP::Cookies, and the core module
HTTP::Tiny only supports the former. There exists
HTTP::CookieJar::LWP to allow using a
HTTP::CookieJar with
LWP::UserAgent, but I can't find anything going the other way- I want to use
HTTP::Cookies::Mozilla with
HTTP::Tiny. In fact, all the modules to read specific browser cookies use the
HTTP::Cookies interface. The following seems to work, but I expected to find some minimal documentation or implementation:
use HTTP::Tiny;
use HTTP::CookieJar;
use HTTP::Cookies::Mozilla;
my $cookies = HTTP::Cookies::Mozilla->new(file => $firefox_cookies_sql
+ite_file);
my @cookies = map { s/^Set-Cookie3:\s*//; $_ }
split "\n", $cookies->as_string;
my $cookie_jar = HTTP::CookieJar->new;
$cookie_jar->load_cookies(@cookies);
my $ua = HTTP::Tiny->new(cookie_jar => $cookie_jar);