Storing downloaded webpages into files

P

PuZzLeD

Hi,
I have a problem here. I am supposed to be saving downloaded web pages
on to a a local cache. I have written a forking proxy server that
reads the request frm the browser and passes the request to the
Internet Gateway and then gets back the data from the internet gateway
and then passes it on to the browser. I need to save the files that
are associated with each request into a local cache. I have attached
the server code below...


server_listenport = IO::Socket::INET->new(
LocalPort => $server_listenport,
Listen => $listen_queuesize)
or die "couldnt be a tcp server on port $server_listenport:
$@\n";


while($browser_request=$server_listenport->accept())
{
if (fork == 0)
{
#child
print " \n\nUsing Child Proceess...\n";
close ($server_listenport);
sysread($browser_request,$req_webpage,2048);
$date_stamp= `date`;
$internet_gateway =IO::Socket::INET->new(
PeerPort=>$IGway_listenport,
PeerAddr=>$IGway_hostname) or die " cannot
connect to gateway";

syswrite($internet_gateway,$req_webpage);

while(sysread($internet_gateway, $recv_webpage, 20480) > 0)
{
syswrite($browser_request,$recv_webpage);
}
print "\n\n\tWeb page is now downloaded!!\n\n";
close($internet_gateway);

exit;
}
}
else
{
#parent
print " \n\nUsing Parent Process...\n";
close($browser_request);
}
} #end of while


Can some1 help me ?
 
B

Ben Morrow

Quoth (e-mail address removed) (PuZzLeD):
Hi,
I have a problem here. I am supposed to be saving downloaded web pages
on to a a local cache. I have written a forking proxy server that
reads the request frm the browser and passes the request to the
Internet Gateway and then gets back the data from the internet gateway
and then passes it on to the browser. I need to save the files that
are associated with each request into a local cache. I have attached
the server code below...

What is your problem? You don't know how to save the data?

You should rewrite this using HTTP::Daemon and LWP, or indeed
HTTP::proxy.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top