logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

HTTP::Tiny::Multipart - Add post_multipart to HTTP::Tiny

Author

       Renee Baecker <reneeb@cpan.org>

Contributors

       •   Stephen Thirlwall

       •   Markvy

       •   Infinoid

       •   Mohammad S Anwar

Name

       HTTP::Tiny::Multipart - Add post_multipart to HTTP::Tiny

Synopsis

           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,
               }
           } );

       creates this request

         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

           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

         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--

Version

       version 0.08

See Also