Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved translation of -F curl flag #2

Closed
szabgab opened this issue Feb 8, 2021 · 1 comment
Closed

improved translation of -F curl flag #2

szabgab opened this issue Feb 8, 2021 · 1 comment

Comments

@szabgab
Copy link

szabgab commented Feb 8, 2021

Trying the following URL on https://corion.net/curl2lwp.psgi gives us some encoded form data

curl -X POST -F field=value -F name=Corion "https://httpbin.org/post" -H  "accept: application/json"

The following "translation" might be better:

use strict;
use warnings;

use LWP::UserAgent ();
use HTTP::Request::Common qw(POST);

my $ua = LWP::UserAgent->new(timeout => 10);
my $url = 'https://httpbin.org/post';
my %content = (
    field => 'value',
    name => 'Corion',
);

my $request = POST $url, 'Content-Type' => 'form-data', Content => \%content;
my $response = $ua->request($request);
print $response->decoded_content;
@Corion
Copy link
Owner

Corion commented Apr 17, 2023

Thank you for suggesting this!

I've implemented this in v0.49 , just released to CPAN

@Corion Corion closed this as completed Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants