c-era has asked for the wisdom of the Perl Monks concerning the following question:
This is the cgi script I wrote. It needs to take the content and not parse, or decode anything and write it out to a file.
use strict; use CGI; if ($ENV{'CONTENT_LENGTH'} > 0 && $ENV{'REQUEST_METHOD'} eq "POST" && +$ENV{"CONTENT_TYPE"} =~ m|^text/xml|){ my $buffer; read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'}); if (length($buffer) != $ENV{'CONTENT_LENGTH'}){ # code to return 400 print "400\n"; exit; } open (FILE,">d:\\test\\test"); print FILE $buffer; close (FILE); # code to return 200 print "200\n"; exit; } # code to return 400 print "400\n"; exit;
Here is a test agent program I wrote that mimics how they will send us data:
use LWP::UserAgent; use strict; my $ua = new LWP::UserAgent; my $content = <<EOF; <test> <test2>test4&;</test2> <test> EOF my $req = new HTTP::Request (POST=>'http://test:test@localhost/cgi-bin +/http/upload.pl'); $req->content_type('text/xml'); $req->content("$content"); print $ua->request($req)->as_string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI.pm problems
by Fletch (Bishop) on Dec 13, 2001 at 22:21 UTC | |
|
Re: CGI.pm problems
by xunker (Beadle) on Dec 13, 2001 at 22:12 UTC | |
by c-era (Curate) on Dec 13, 2001 at 22:29 UTC | |
by chromatic (Archbishop) on Dec 13, 2001 at 23:28 UTC | |
by c-era (Curate) on Dec 13, 2001 at 23:54 UTC | |
by perrin (Chancellor) on Dec 13, 2001 at 22:39 UTC | |
by c-era (Curate) on Dec 13, 2001 at 23:56 UTC | |
by perrin (Chancellor) on Dec 14, 2001 at 00:34 UTC | |
|
Re: CGI.pm problems
by sevensven (Pilgrim) on Dec 14, 2001 at 01:16 UTC | |
|
Re: CGI.pm problems
by chip (Curate) on Dec 14, 2001 at 01:47 UTC | |
|
Re: CGI.pm problems
by Illiad (Initiate) on Dec 14, 2001 at 04:07 UTC | |
|
Re: CGI.pm problems
by CMonster (Scribe) on Dec 14, 2001 at 06:35 UTC | |
by c-era (Curate) on Dec 14, 2001 at 19:24 UTC |