Skip to content

Commit

Permalink
NEW FEATURE: '--cookie-jar' option for saving response cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
bayashi committed Jul 13, 2013
1 parent ccacc10 commit b097baa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ my $builder = Module::Build->new(
'Pod::Usage' => 0,
'LWP::UserAgent' => 0,
'HTTP::Request' => 0,
'HTTP::Cookies' => 0,
'Data::Printer' => 0,
'JSON::Pointer' => 0,
'JSON' => 0,
Expand Down
8 changes: 8 additions & 0 deletions lib/App/aki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use warnings;
use Getopt::Long qw/GetOptionsFromArray/;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
use Data::Printer qw//;
use Encode qw//;
use File::Spec;
Expand Down Expand Up @@ -77,6 +78,12 @@ sub run {

my $res = _request($config);

if ($config->{cookie_jar}) {
my $cookie_jar = HTTP::Cookies->new;
$cookie_jar->extract_cookies($res);
$cookie_jar->save($config->{cookie_jar});
}

if ($config->{raw}) {
print $res->content;
exit;
Expand Down Expand Up @@ -305,6 +312,7 @@ sub _merge_opt {
'timeout=i' => \$config->{timeout},
'H|header=s@' => \$config->{header},
'b|cookie=s' => \$config->{cookie},
'c|cookie-jar=s' => \$config->{cookie_jar},
'u|user=s' => \$config->{user},
'p|pointer=s' => \$config->{pointer},
'ie|in-enc=s' => \$config->{in_enc},
Expand Down
1 change: 1 addition & 0 deletions script/aki
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aki - The command-line data processor for web content
-m, --method HTTP method(default: GET)
-H, --header request header
-b, --cookie cookie file path for request
-c, --cookie-jar file path for saving response cookie
-u, --user basic authentication credentials( "user:passwd" )
-p, --pointer JSON pointer string(See: JSON::Pointer)
-ie, --in-enc input encoding(default: utf8)
Expand Down

0 comments on commit b097baa

Please sign in to comment.