Logo

Programming-Idioms

History of Idiom 174 > diff from v10 to v11

Edit summary for version 11 by wbazant:
New Perl implementation by user [wbazant]

Version 10

2019-09-26, 20:32:02

Version 11

2019-09-26, 20:36:52

Idiom #174 Make HTTP POST request

Make a HTTP request with method POST to URL u

Idiom #174 Make HTTP POST request

Make a HTTP request with method POST to URL u

Imports
use LWP::UserAgent;
Code
# Create a user agent object

my $ua = LWP::UserAgent->new;
 
# Create a request
my $req = HTTP::Request->new(POST => $u);
 
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
 
# Check the outcome of the response
if ($res->is_success) {
    print $res->content;
}
else {
    print $res->status_line, "\n";
}
Comments bubble
Using LWP
Doc URL
https://metacpan.org/pod/LWP
Origin
https://metacpan.org/pod/LWP