Someone else has probably thought of this before me, but I'm posting this since I dreamt it up and produced working code in about 5 minutes. I was yet again amazed at Perl and CPAN!
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Archive::Tar; my $cgi = CGI->new(); my $tar = Archive::Tar->new('foobar.tar.gz'); my $file = $cgi->path_info(); $file =~ s|^/||; print $cgi->header(), $tar->get_content($file);
Say you have called this script foobar.cgi, and have a tarball called foobar.tar.gz - then you'll get the archived file foo/bar.html out of the archive if you request http://servername/foobar.cgi/foo/bar.html. In fact if your webserver is properly configured you could call it just, say, documents, and the URL would look like http://servername/documents/foo/bar.html, giving your visitors not the least hint that anything unusual is happening, besides the rather long load time.
There's some quick&dirty bits there -
Unfortunately, it easily spikes your CPU load to 100% and drains lots of memory for long stretches if a HTML page refers to images stored within the tarball causing multiple concurrent CGIs ungzipping/untarring the archive. I tried performance with Archive::Zip, but didn't get any better results, unfortunately.
So there. Utterly useless for any practical purposes but just dead cool. :-) What do you think?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 1: Serving tarball contents as part of your webspace (impractical but fun)
by tilly (Archbishop) on Jan 05, 2002 at 19:26 UTC | |
by Aristotle (Chancellor) on Jan 05, 2002 at 22:29 UTC | |
Re: Serving tarball contents as part of your webspace (impractical but fun)
by merlyn (Sage) on Jan 11, 2002 at 08:52 UTC | |
Re: Serving tarball contents as part of your webspace (impractical but fun)
by pokemonk (Scribe) on Jan 03, 2002 at 22:34 UTC |