and the Perl code (handleput.cgi) that forwards the curl request to the url specified.curl -T abc.gz -X PUT -H "User-Agent: MyUA" http://xxxx.com/cgi-bin/ha +ndleput.cgi -v
Do I need to add the filename from $ENV{'PATH_INFO'} to the PPut url, so the final created will be abc.gz instead of PPut.gz ?#!/usr/bin/perl -w use LWP::UserAgent; use HTTP::Request; use HTTP::Response; use HTTP::Headers; use HTTP::Status qw(:constants :is status_message); use CGIWrapper; ##instance for CGI my $url = 'http://xxxx/testput/PPut'; main(); exit(0); sub main() { my $cgi = new CGIWrapper(); my $ua = LWP::UserAgent->new; my %headers = map { $_ => $cgi->http($_) } $cgi->http; my $req_headers = HTTP::Headers->new( %headers ); my $readData = sub { read(STDIN, my $buf, 65536); return $buf; }; $req = HTTP::Request->new("PUT", $url, $req_headers, $readData) if + ($ENV{'REQUEST_METHOD'} eq 'PUT'); print STDOUT $cgi->header(-type=>'text/plain'); print STDOUT $req->as_string(),"\n"; $res = $ua->request($req); if($res->is_success) { print STDOUT $res->code,' ', $res->message,"\n"; } else{ print STDOUT $res->status_line, "\n"; } } Below are the headers captured by the above script: <code> PUT http://xxxx/testput/PPut Cache-Control: no-store Connection: close Expect: 100-continue User-Agent: MyUA Content-Length: 248329 Content-Type: application/x-gzip-compressed Request-Method: PUT PATH-INFO: /abc.gz
In reply to Anything wrong with the LWP PUT code by chanakya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |