### ----------------------------------------------------
### -- HTTP::Client
### -- Licenses: Artistic-2.0
### -- Authors: Timothy Totten
### -- File: t/03-post-multipart.t
### ----------------------------------------------------
use v6;
use HTTP::Client;
use Test;

plan 5;

my $http = HTTP::Client.new;
#my $res = $htto.get('http://huri.net/test.txt');
my $req = $http.post(:multipart);
#$req.url('http://127.0.0.1:8080/test.txt');
$req.url('https://eu.httpbin.org/post');
$req.add-field(:id<1984>);
$req.add-file(
  :name("upload"),     :filename("test.txt"), 
  :type("text/plain"), :content("Hello world.\nThis is a test.\n")
);
my $res = $req.run;
#$*ERR.say: "~Status: "~$res.status;
#$*ERR.say: "~Message: "~$res.message;
#$*ERR.say: "~Proto: "~$res.protocol;
ok $res, "Constructed result object from direct get() call.";
ok $res.success, "Result was successful.";
my $content = $res.content;
#$*ERR.say: "~Content: $content";
#$*ERR.say: "~Headers: "~$res.headers.perl;
ok $content, "Content was returned.";

ok $content ~~ /Client/, "Content was correct.";
ok $res.header('Content-Type') ~~ /^application/, "Correct content type.";



