NAME
HTTP::Request::CurlParameters - container for a Curl-like HTTP request
SYNOPSIS
my $ua = LWP::UserAgent->new;
my $params = HTTP::Request::CurlParameters->new(argv => \@ARGV);
my $response = $ua->request($params->as_request);
DESCRIPTION
Objects of this class are mostly created from HTTP::Request::FromCurl. Most likely you want to use that module instead:
my $ua = LWP::UserAgent->new;
my $params = HTTP::Request::FromCurl->new(command_curl => $cmd);
my $response = $ua->request($params->as_request);
METHODS
->new
Options:
methodmethod => 'GET'The HTTP method to use.
uriuri => 'https://example.com'The URI of the request.
headersheaders => { 'Content-Type' => 'text/json', 'X-Secret' => ['value-1', 'value-2'], }The headers of the request. Multiple headers with the same name can be passed as an arrayref to the header key.
cookie_jarThe cookie jar to use.
cookie_jar_optionsOptions for the constructor of the cookie jar.
credentialscredentials => 'hunter2:secret'The credentials to use for basic authentication.
authauth => 'basic'The authentication method to use.
post_datapost_data => ['A string','across multiple','scalars']The POST body to use.
bodybody => '{"greeting":"Hello"}'The body of the request.
timeouttimeout => 50The timeout for the request
unix_socketunix_socket => '/var/run/docker/docker.sock'The timeout for the request
local_addresslocal_address => '192.0.2.116'The local network address to bind to when making the request
form_argsThe HTML form parameters. These get converted into a body.
insecureinsecure => 1Disable SSL certificate verification
certcert => '/path/to/certificate',Use the certificate file for SSL
capathcapath => '/path/to/cadir/',Use the certificate directory for SSL
outputName of the output file
max_filesizeMaximum size (in bytes) of a file to download
show_errorshow_error => 0Show error message on HTTP errors
failfail => 1Let the Perl code
dieon error
->as_request
$ua->request( $r->as_request );
Returns an equivalent HTTP::Request object
$r->as_request
my $r = $curl->as_request;
Returns a HTTP::Request object that represents the Curl options.
$r->as_snippet( %options )
print $r->as_snippet( type => 'LWP' );
Returns a code snippet that returns code to create an equivalent HTTP::Request object and to perform the request using WWW::Mechanize.
This is mostly intended as a convenience function for creating Perl demo snippets from curl examples.
Options
- implicit_headers
-
Arrayref of headers that will not be output.
Convenient values are ['Content-Length']
- type
-
type => 'Tiny',Type of snippet. Valid values are
LWPfor LWP::UserAgent,Mojoliciousfor Mojolicious::UserAgent andTinyfor HTTP::Tiny.
$r->as_curl
print $r->as_curl;
Returns a curl command line representing the request
This is convenient if you started out from something else or want a canonical representation of a curl command line.
- curl
-
The curl command to be used. Default is
curl.
$r->as_wget
print $r->as_wget;
Returns a curl command line representing the request
This is convenient if you started out from something else or want a canonical representation of a curl command line.
- wget
-
The curl command to be used. Default is
wget.
$r->clone
Returns a shallow copy of the object
REPOSITORY
The public repository of this module is http://github.com/Corion/HTTP-Request-FromCurl.
SUPPORT
The public support forum of this module is https://perlmonks.org/.
BUG TRACKER
Please report bugs in this module via the Github bug queue at https://github.com/Corion/HTTP-Request-FromCurl/issues
AUTHOR
Max Maischein corion@cpan.org
COPYRIGHT (c)
Copyright 2018-2023 by Max Maischein corion@cpan.org.
LICENSE
This module is released under the same terms as Perl itself.