HTTP::...ltipart(3pm)

πŸ“¦
version 0.08 Β· 7 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– HTTP::Tiny::Multipart β€” the manual, but make it slay πŸ’–

okay bestie, so this is the User Contributed Perl Documentation for HTTP::Tiny::Multipart β€” a lil' module that gives your fave tiny HTTP client a whole new trick. Pull up a chair, we're doing this together 🫢


✨ NAME ✨

HTTP::Tiny::Multipart β€” it adds post_multipart to HTTP::Tiny. that's it, that's the whole vibe. no cap.


🌸 VERSION 🌸

version 0.08

(yeah, she's on 0.08, respect the journey πŸ’…)


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so first thing first, load both of them up:

use HTTP::Tiny;
use HTTP::Tiny::Multipart;

my $http = HTTP::Tiny->new;

my $content = "This is a test";

my $response = $http->post_multipart( 'http://localhost:3000/', {
    file => {
        filename => 'test.txt',
        content  => $content,
    }
} );

and this is the request it creates. look at it. it's giving multipart. it's giving boundary=go7DX:

POST / HTTP/1.1
Content-Length: 104
User-Agent: HTTP-Tiny/0.025
Content-Type: multipart/form-data; boundary=go7DX
Connection: close
Host: localhost:3000

--go7DX
Content-Disposition: form-data; name="file"; filename="test.txt"

This is a test
--go7DX--

And also β€” this one here, where we're adding a content_type to the file AND a plain testfield alongside it:

use HTTP::Tiny;
use HTTP::Tiny::Multipart;

my $http = HTTP::Tiny->new;

my $content = "This is a test";

my $response = $http->post_multipart( 'http://localhost:3000/', {
    file => {
        filename => 'test.txt',
        content  => $content,
        content_type  => 'text/plain',
    },
    testfield => 'test'
} );

creates this:

POST / HTTP/1.1
Content-Length: 104
User-Agent: HTTP-Tiny/0.025
Content-Type: multipart/form-data; boundary=go7DX
Connection: close
Host: localhost:3000

--go7DX
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain

This is a test
--go7DX
Content-Disposition: form-data; name="testfield"

test
--go7DX--

see how the content_type shows up as its own header inside the part, and testfield just rides along as a regular field? iconic behaviour. the way that multipart bodies just work πŸ˜­πŸ’–


πŸ‘‘ CONTRIBUTORS πŸ‘‘

these are the people who helped make it happen, show them some love fr fr:

  • Stephen Thirlwall
  • Markvy
  • Infinoid
  • Mohammad S Anwar

πŸ’œ AUTHOR πŸ’œ

Renee Baecker <reneeb@cpan.org> β€” main character energy, honestly.


This software is Copyright (c) 2018 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)
bestie, it's free software β€” read the license, it's right there, don't be weird about it πŸ’€

and that's the whole page!! this was perl v5.36.0, dated 2022-12-04, and it lives under HTTP::...ltipart(3pm) in the User Contributed Perl Documentation. go forth and multipart your little heart out 🧚✨🌸