in reply to Mojo instead of curl
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'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mojo instead of curl
by NERDVANA (Priest) on Apr 14, 2023 at 17:48 UTC | |
by Corion (Patriarch) on Apr 14, 2023 at 18:20 UTC | |
by NERDVANA (Priest) on Apr 14, 2023 at 19:53 UTC |