Reputation: 1492
I tried to use CGI.pm (3.15), but it can't handle PUT requests.
I'm building a REST API, so I need methods PUT, GET, POST and DELETE.
Any ideas?
Code:
#!/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:
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 and data always empty.
Upvotes: 1
Views: 600
Reputation: 1492
I found it!
The solution was doing an update to the perl module CGI to 3.63 and now works fine.
Upvotes: 2