I need to open a HTTP connection to a local machine, get the
response data (a JPEG image) and then pass that on to the client
- this is necessary as (1) the images are stored on a computer
that is not visible publically and (2) I need to check that the
client is authorised to see a particular image before returning
it.
As a standalone Perl script, this works fine:
use Win32::Internet;
print "Content-type: image/jpeg\r\n\r\n";
$theURL = 'http://an.IP.addr.ess/lib/foo.jpg';
$Connection = Win32::Internet->new();
$file = $Connection->FetchURL($theURL);
binmode( STDOUT );
print $file;
But I have to run the code from within an ASP page as the username
and password for access are stored in Session variables.
This doesn't work at all - I get a zero byte content-length:
<%@ Language=PerlScript %><%
use Win32::Internet;
use Win32::OLE;
$Connection = Win32::Internet->new();
$Response->{Buffer} = 1;
$Response->Clear;
$Response->{ContentType} = 'image/jpeg';
$file = $Connection->FetchURL('http://an.IP.addr.ess/lib/foo.jpg');
$Response->BinaryWrite(Win32::OLE::Variant->new( VT_UI1, $file ));
$Response->End;
%>
Interestingly, just $Response->BinaryWrite($file); gives me _a_ response,
but it is pretty garbled (it has an extra 16 bytes at the start, and
is about 1/10th of the correct length). Now, I've read enough to
know why writing the file directly won't work, but I don't understand
why I'm not getting a response at all.
The JPEG in question is c. 192K (so I should be reading and writing
chunks, but I can't get that to work in ASP either :()
I'm going mad here...
--
Mike Trinder [EMAIL PROTECTED]
Miller Hare Limited http://www.millerhare.com
4 Fitzroy Square telephone: +44 20.7691.1000
London W1T 5HQ facsimile: +44 20.7691.1001
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web