use strict; use warnings; use WWW::Curl::Easy; use WWW::Curl::Form; use Encode; my $hdr; my $curl = WWW::Curl::Easy->new(); $curl->setopt(CURLOPT_NOPROGRESS, 1); # shut off the built-in progress meter $curl->setopt(CURLOPT_HEADER, 0); # don't include hdr in body $curl->setopt(CURLOPT_ENCODING, 'gzip'); $curl->setopt(CURLOPT_PROXY, ''); # no proxy open my $fh, ">", \$hdr; $curl->setopt(CURLOPT_WRITEHEADER, $fh); $curl->setopt(CURLOPT_URL, 'http://xxx.yyy.zzz:82/vx'); post(); print "FIRST HEADER $hdr\n\n"; $hdr = ''; sleep 2; post(); print "SECOND HEADER $hdr\n"; sub post { my $form = WWW::Curl::Form->new; $curl->setopt(CURLOPT_HTTPHEADER, ['Expect:','']); $form->formadd('method', 'login'); $form->formadd('username', 'xxx'); $form->formadd('password', 'xxx'); $curl->setopt(CURLOPT_HTTPPOST, $form); my $response_body; $curl->setopt(CURLOPT_WRITEDATA,\$response_body); my $retcode = $curl->perform; if ($retcode != 0) { die "post_request failed (", $retcode, " - ", $curl->errbuf, ")"; } my $decoded_content = decode ('utf-8', $response_body); }