curl -H "User-Agent: myBrowser" -H "X-version: 2" -H "X-subject: MyTest001" -d@/tmp/SAMPLE.gz -X POST http://mycompany.xxx.com/2.0/post -v #### < HTTP/1.1 200 OK < Date: Tue, 12 Apr 2011 18:13:15 GMT < Content-Length: 0 < X-Powered-By: Servlet/2.5 JSP/2.1 * Connection #0 left intact * Closing connection #0 #### curl -H "User-Agent: myBrowser" -H "X-version: 2" -H "X-subject: MyTest001" -d@/tmp/SAMPLE.gz -X POST http://testmachine.xxx.com/cgi-bin/postreq.pl -v #### #!/usr/bin/perl use strict; use HTTP::Request::Common qw{POST}; use HTTP::Response; use HTTP::Headers; use HTTP::Status qw(:constants :is status_message); use CGIWrap; use LWP::UserAgent; my $url='http://mycompany.xxx.com/2.0/post'; main(); exit(0); sub main() { my $cgi = new CGIWrap(); 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; }; my $req = HTTP::Request->new("POST", $url, $req_headers, $readData) print STDOUT $cgi->header(-type=>'text/plain'); print STDOUT $req->as_string(),"\n"; my $res = $ua->request($req); if($res->is_success) { print STDOUT $res->code,' ', $res->message,"\n"; } else{ print STDOUT $res->status_line, "\n"; } } #### Content-Length: 284257 Content-Type: application/x-www-form-urlencoded < HTTP/1.1 200 OK < Date: Tue, 12 Apr 2011 18:15:16 GMT < Server: Apache < < Transfer-Encoding: chunked < Content-Type: text/plain; charset=ISO-8859-1 POST http://mycompany.xxx.com/2.0/post HTTP-USER-AGENT: myBrowser HTTP-X-SUBJECT: MyTest001 403 Forbidden * Connection #0 left intact * Closing connection #0