Created
February 25, 2016 05:08
-
-
Save yowcow/de42d75238276e65d72a to your computer and use it in GitHub Desktop.
Multipart form data with HTTP::Request::Common
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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