[EMAIL PROTECTED] wrote: > Sorry to be late... > > >>Try a different content type : > > > I tried it, and ok the body was sent as binary data, > but the server side pgm semms to expect the Content-Type > to be the one I said before "'application/bang-gzip'.
Do you have control of the server-side program ? If so, you can modify it. If not, then you need to keep POST from changing the transfer encoding. When I use application/bang-gzip as the content type, it goes out in binary (not base64 encoded), so I'm not sure why yours is encoding it. Request (as string): POST http://localhost:83/cgi-bin/env.pl User-Agent: libwww-perl/5.803 Content-Length: 267 Content-Type: application/bang-gzip âââ9 âlicenses__.xml mâ;kâ0â Î=à âÂ'Sj2ââÃâ0tÎââ1Ââ%=âââJâ }â8uâ"mÂÎâwr7Xâ>1âÎ] âÃ;ââââkrÏÃâââ6[âÂâ+â)`â}âÂââ>iÂEâ#âf_ÂââgÃâ8LMÂoNÎmÂâxtâ"ÃâÃjÏÃâÂâDÃÃÃÃQ)HâV.Â" EÃÂâ}xÃsâbNÂ"[EMAIL PROTECTED]<JÂâ^âpÎ(ÃGÂ"âOâââÃTÃT;]ÎDÂgâ[ââ Ãà â>ÂKÂâÎâÃ!ââzââÂÃP'ââ The above shows the data in binary (not encoded). Response (as string) - content trimmed at ...'s : HTTP/1.1 200 OK Connection: close Date: Mon, 09 May 2005 04:37:53 GMT Server: Apache/2.0.52 (Win32) DAV/2 Content-Language: en Content-Type: text/html; charset=ISO-8859-1 Client-Date: Mon, 09 May 2005 04:37:53 GMT Client-Peer: 127.0.0.1:83 Client-Response-Num: 1 Client-Transfer-Encoding: chunked Title: Env Feedback X-Meta-Robots: noindex,nofollow ... Important fields: <BR>CONTENT_LENGTH = 267 <BR>CONTENT_TYPE = application/bang-gzip <BR>REQUEST_METHOD = POST ... Script (receiving script is just printing env out etc) : use strict; use LWP::UserAgent; use HTTP::Request::Common qw(POST); use File::Copy; # copy input xml file into "gz" my $inXML = shift; die "File $inXML not found" unless -f $inXML; die "File $inXML must be '*.xml'" unless $inXML =~ /\.xml$/; (my $inXML_gz = $inXML) =~ s/\.xml$/__.xml/; copy ($inXML, $inXML_gz) or die "Copy ($inXML, $inXML_gz) failed: $!"; my $rc = `gzip $inXML_gz`; die "command 'gzip' returned nonzero $rc, check it!" if $rc; $inXML_gz .= ".gz"; die "GZ File $inXML_gz not found" unless -f $inXML_gz; open GZ, $inXML_gz or die "Open error $inXML_gz: $!"; my $gzlen = -s GZ; # size of file my $bufTmp; read GZ, $bufTmp, $gzlen; close GZ; print "OK get gziped data, length: $gzlen\n"; (my $outXML = $inXML) =~ s/\.xml$/_out.xml/; my $ua = LWP::UserAgent->new; my $url = 'http://localhost/mytest/servlet/AcceptServlet'; $url = 'http://localhost:83/cgi-bin/env.pl'; my $req = POST $url, Content_Type => 'application/bang-gzip', Content => $bufTmp; my $res = $ua->request($req); die "Request failed: ", $res->status_line unless $res->is_success; print "OK request, data saved into file $outXML\n"; print "Request:", $req->as_string(); print "Response:", $res->as_string(); __END__ -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
