Fixup taking content as a hash. Use URI to convert it to a string. Add headers support in post.

This commit is contained in:
Isaac Connor
2025-11-24 16:23:28 -05:00
parent 19a6d920e8
commit 5bb4caab8f

View File

@@ -374,9 +374,15 @@ sub post {
return;
}
$url = $$self{BaseURL}.$url if $$self{BaseURL};
my $req = HTTP::Request->new(POST => $url);
my $content = shift;
my $content = shift if @_;
my $headers = shift if @_;
my $req = HTTP::Request->new('POST', $url, $headers);
if ( defined($content) ) {
if (ref $content eq 'HASH') {
my $uri = $$self{uri};
$uri->query_form(%{$content});
$content = $uri->query;
}
$req->content_type('application/x-www-form-urlencoded; charset=UTF-8');
$req->content($content);
}