我想这样做:
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
答案 0 :(得分:4)
LWP :: UserAgent :: delete()中的参数用于创建标题而不是内容。使用HTTP:请求:
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;