问题
I'm trying to change this request to a HTTP PUT request, any idea how ?
my $request = LWP::UserAgent->new;
my $response =
$request->get($url, "apikey", $apiKey, "requestDate", $requestDate);
回答1:
You should use HTTP::Request:
use LWP::UserAgent;
use HTTP::Request;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new("PUT", $url);
my $res = $ua->request($req);
回答2:
As of 6.04, LWP::UserAgent
has a put
helper, so you can now do:
$ua->put( $url )
回答3:
PUT is HTTP::Request::Common. You can build the request first and pass it into user agent.
use HTTP::Request::Common;
use LWP;
$agent = LWP::UserAgent->new;
$request = HTTP::Request::Common::PUT($url, "apikey", $apiKey, "requestDate", $requestDate);
$response = $agent->request($request);
来源:https://stackoverflow.com/questions/8463187/how-to-make-a-http-put-request-using-lwp