My send/receive code is working fine (apparently) for HTML and also for text
(although oddly, text comes back from the remote CGI with a Content-type of
text/x-usenet-faq which neither I nor my browser had heard of, so it was
being downloaded instead of displayed; took me ages to figure out).

Anyway, my problem is when the response is binary, e.g. a compressed archive,
a JPEG, a GIF.

As near as I can determine, I am losing a bunch of ^L (ASCII \012) in the
response content.  Is there something special I need to do to say "it's
binary, it's not a string, leave it alone"?


    my ($host, $port, $doc)=@_;

    my $ua=new LWP::UserAgent;
    my $req = new HTTP::Request 'GET', "http://$host$doc";;


    my $response = $ua->request($req);  # returns a hashref

    my $hdrs = $response->headers->as_string();
    my $result = $response->status_line;
    my $content = $response->content();

    return($content, $result, $hdrs);

On the other side, if I run the returned $content through a filter
    $string =~ s/([^a-zA-Z0-9_])/sprintf("\\%03o", ord($1))/eg;
and then compare the result with the original file (before I ut it on the
server), the "new" version I got back through LWP is missing a bunch of \012.

If I bypass the LWP gateway and go directly to the remote CGI, the files are
not mangled.

Is this another simple thing I can't seem to find in the docs?
-- 
- Vicki

Vicki Brown     ZZZ                  Journeyman Sourceror:
P.O. Box 1269      zz  |\     _,,,---,,_        Scripts & Philtres
San Bruno, CA       zz /,`.-'`'    -.  ;-;;,_     Perl, Unix, MacOS
94066     USA         |,4-  ) )-,_. ,\ ( `'-'
mailto:[EMAIL PROTECTED]  '---''(_/--'  `-'\_)  http://www.cfcl.com/~vlb

Reply via email to