我尝试使用 CGI.pm (3.15),但它无法处理 PUT 请求。
我正在构建一个 REST API,所以我需要 PUT、GET、POST 和 DELETE 方法。
有任何想法吗?
代码:
#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
main: {
print "Content-Type: text/html; charset=utf-8\n\n";
my $query = CGI->new;
my $value1 = $query->param('param1');
my $value2 = $query->param('param2');
my $data = $query->param('PUTDATA');
print "value1[$value1] value2[$value2] data[$data]\n";
};
卷曲:
curl 'http://localhost/cgi-bin/testing.cgi' -X PUT -H 'Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: 192.168.8.197' -H 'Accept-Language: es-419,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: */*' -H 'Connection: keep-alive' --data 'param1=hola¶m2=hola' --compressed
value1、value2 和 data 始终为空。