in reply to How do I make a multipart/mixed request (for REST API) in Perl?
EDIT: I'm an idiot and as the other reply here shows, HTTP::Message already has this functionality built-in. ->add_part() is your friend. I should have looked a bit harder.
OK, so what you're looking for I haven't yet found on the CPAN. This is _completely_ untested, so please take it with a grain of salt (or 100 such grains).
You can create multiple HTTP::Request objects (get, post, etc). You can then group them all together in one new HTTP::Request object with a fairly simple function like I'm showing below and then just send that request:
use UUID qw(uuid); use HTTP::Request (); use Encode (); sub build_multi { my ($method, $uri, $header, @requests) = @_; my $r = HTTP::Request->new($method, $uri, $header); my $boundary = uuid(); $r->header( 'Content-Type' => "multipart/mixed; boundary=$boundary" ); my $content = ''; for my $req (@requests) { $content .= $r->as_string("\015\012"); $content .= "\015\012--{$boundary}"; } $content .= '--' if $content; $r->content( Encode::encode_utf8($content) ); return $r }
AGAIN: completely untested
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I make a multipart/mixed request (for REST API) in Perl?
by Your Mother (Archbishop) on Nov 28, 2017 at 16:40 UTC | |
|
Re^2: How do I make a multipart/mixed request (for REST API) in Perl?
by Anonymous Monk on Nov 28, 2017 at 16:28 UTC | |
by Your Mother (Archbishop) on Nov 28, 2017 at 16:35 UTC |