See also my converter from curl to Perl at https://corion.net/curl2lwp.psgi:

#!perl use strict; use warnings; use HTTP::Tiny; my $ua = HTTP::Tiny->new(); my $res = $ua->request( 'POST' => 'https://my.webpage.com/my/path', { headers => { 'Content-Length' => '15', 'User-Agent' => 'curl/7.55.1', 'My-Header-2' => 'beta', 'My-Header' => 'alfa', 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => '*/*' }, content => "here is my data" }, ); __END__ Created from curl command line curl -kv -X POST "https://my.webpage.com/my/path" --header 'My-Header: alfa' --header 'My-Header-2: beta' --data-raw 'here is my data'

But your question gives me an idea - I should also add a converter option to output Mojolicious code.

Update: The app now also supports Mojolicious output:

#!perl use strict; use warnings; use Mojo::UserAgent; my $ua = Mojo::UserAgent->new( 'insecure' => '1' ); my $tx = $ua->build_tx( 'POST' => 'https://my.webpage.com/my/path', { 'Accept' => '*/*', 'User-Agent' => 'curl/7.55.1', 'Content-Length' => '15', 'Content-Type' => 'application/x-www-form-urlencoded', 'My-Header' => 'alfa', 'My-Header-2' => 'beta' }, "here is my data" ); my $res = $ua->start($tx)->result; __END__ Created from curl command line curl -kv -X POST "https://my.webpage.com/my/path" --header 'My-Header: alfa' --header 'My-Header-2: beta' --data-raw 'here is my data'

In reply to Re: Mojo instead of curl by Corion
in thread Mojo instead of curl by leszekdubiel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.