Please excuse yadq (yet another dumb question). SiGh.
One of my calls to the "remote CGI" returns a raw JPEG
my $ua = new LWP::UserAgent;
my $req;
if ($port == 80) {
$req = new HTTP::Request GET => "http://$host$doc";
} else {
$req = new HTTP::Request GET => "http://$host:$port/$doc";
}
my $response=$ua->request($req); # hash ref; HTTP::Response object
$resp=$response->as_string;
$hdrs=$response->headers->as_string();
if ($response->is_success) {
$resp=$response->content();
}
Headers ($hdrs):
Connection: close
Date: Tue, 23 Apr 2002 04:56:29 GMT
Server: Apache/1.3.6 (Unix) ApacheJServ/1.0
Content-Length: 11093
Content-Type: image/jpeg
Client-Date: Tue, 23 Apr 2002 05:02:38 GMT
Client-Peer: 10.0.0.4:80
Content-Disposition: inline; filename="UFkit7.jpg"
Content-Transfer-Encoding: binary
MIME-Version: 1.0
Response ($resp):
a bunch of binary stuff
When the result is HTML I just print it to the new page. But this isn't
HTML; I can't wrap it in <HTML...</HTML> tags. I can't simply print it (the
CGI at _my_ end gives an error).
Is there a convention for handling returns of binary image data?
The person who "owns" the CGI that sends me the binary stream says:
We normally handle these by returning a page with the
correct "Content-length:.." and "Content-type: ..." which the browser
is supposed to interpret and display accordingly.
I guess I'm "the browser" in this case. It may be that the flaw is in "my"
CGI (the
one I'm working with; I didn't write it) in its inability to handle a page
consisting of a simple
print $resp;
I get an error in the Apache log
malformed header from script. Bad header=����:
I believe it. JPEG binary code does not make a well-formed HTML header...
Help? I have all the info I think I need in the headers and the content if I
can just convince the page to draw it and accept it.
--
- 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