Sorry to be late...
(B
(B> Try a different content type :
(B
(BI tried it, and ok the body was sent as binary data,
(Bbut the server side pgm semms to expect the Content-Type
(Bto be the one I said before "'application/bang-gzip'.
(B
(BRegards,
(BHirosi Taguti
(B[EMAIL PROTECTED]
(B
(B
(B> [EMAIL PROTECTED] wrote:
(B>
(B> > Hello,
(B> >
(B> > I have some trouble making a script with LWP.
(B> > I'm writing a client program "wc_client",
(B> > emulating an existing request which sends gzip'ed xml data to
(B> > our server.
(B> > My script "wprint" running on port 80 printed out the request,
(B> > first of which is produced by "wc_client", but it is encoded with
(B> > Base64 or so. The real request is not encoded but a bianay data.
(B> >
(B> > How can I suppress the LWP's auto encoding of the binary body data?
(B>
(B> Try a different content type :
(B>
(B> # wc_client: request bin data to sever
(B>
(B> use strict;
(B> use LWP::UserAgent;
(B> use HTTP::Request::Common qw(POST);
(B> use File::Copy;
(B>
(B> # copy input xml file into "gz"
(B>
(B> my $inXML = shift;
(B> die "File $inXML not found" unless -f $inXML;
(B> die "File $inXML must be '*.xml'" unless $inXML =~ /\.xml$/;
(B> (my $inXML_gz = $inXML) =~ s/\.xml$/__.xml/;
(B> copy ($inXML, $inXML_gz) or die "Copy ($inXML, $inXML_gz) failed: $!";
(B> my $rc = `gzip $inXML_gz`;
(B> die "command 'gzip' returned nonzero $rc, check it!" if $rc;
(B>
(B> $inXML_gz .= ".gz";
(B> die "GZ File $inXML_gz not found" unless -f $inXML_gz;
(B> open GZ, $inXML_gz or die "Open error $inXML_gz: $!";
(B> my $gzlen = -s GZ; # size of file
(B> my $bufTmp;
(B> read GZ, $bufTmp, $gzlen;
(B> close GZ;
(B>
(B> print "OK get gziped data, length: $gzlen\n";
(B> (my $outXML = $inXML) =~ s/\.xml$/_out.xml/;
(B>
(B> my $ua = LWP::UserAgent->new;
(B> my $url = 'http://localhost/mytest/servlet/AcceptServlet';
(B> my $req = POST $url, Content_Type => 'application/octet-stream',
(B> Content => $bufTmp;
(B> my $res = $ua->request($req);
(B> die "Request failed: ", $res->status_line unless $res->is_success;
(B> print "OK request, data saved into file $outXML\n";
(B> print $req->as_string();
(B>
(B> __END__
(B
(B_______________________________________________
(BPerl-Win32-Users mailing list
([email protected]
(BTo unsubscribe: http://listserv.ActiveState.com/mailman/mysubs