Skip to content

Instantly share code, notes, and snippets.

@yowcow
Created February 25, 2016 05:08
Show Gist options
  • Save yowcow/de42d75238276e65d72a to your computer and use it in GitHub Desktop.
Save yowcow/de42d75238276e65d72a to your computer and use it in GitHub Desktop.
Multipart form data with HTTP::Request::Common
use common::sense;
use HTTP::Request::Common;
use LWP::UserAgent;
{
my $req = POST 'http://localhost:8888/test.php',
Content_type => 'form-data',
Content => {
myname => 'hogefuga',
myfile1 => [ 'file.txt', 'file.txt' ],
myfile2 => [ 'file.txt', 'file.txt' ],
};
say "==== Request ====";
say $req->as_string;
my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);
say "==== Response ====";
say $res->as_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment