2

我想要做:

 curl -X DELETE -d '{"name":"flowx"}' 'http://somewhere/wm/staticflowentrypusher/json'

在 perl 中:

 my $browser = LWP::UserAgent->new;
 my $url = 'http://somewhere/wm/staticflowentrypusher/json';
 $browser->delete($url, '{"name":"flowx"}');

但我得到:

 Illegal field name '{"name":"flowx"}' at /home/user/perl5/lib/perl5/HTTP/Request/Common.pm line 115
4

1 回答 1

5

LWP::UserAgent::delete() 中的参数用于创建标题而不是内容。使用 HTTP:Request :

my $browser = LWP::UserAgent->new;
my $url = 'http://somewhere/wm/staticflowentrypusher/json';

my $req = HTTP::Request->new(DELETE => $url);

$req->content('{"name":"flowx"}');
my $response = $browser->request($req);

say $response->content;
于 2013-08-05T11:26:59.330 回答