我尝试使用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和数据始终为空。
答案 0 :(得分:2)
我找到了它!
解决方案是将perl模块CGI更新到3.63,现在工作正常。