Import 0.99
This commit is contained in:
61
static.pl
Normal file
61
static.pl
Normal file
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# SMArT
|
||||
#
|
||||
# Static file server
|
||||
#
|
||||
# Copyright 2001 Wilmer van der Gaast (lintux@lintux.cx)
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#
|
||||
|
||||
sub handle_request()
|
||||
{
|
||||
$f = $c[1];
|
||||
$f =~ s/[^-_\.A-Za-z0-9]//g;
|
||||
if( ! open( FILE, $base . 'static/' . $f ) )
|
||||
{
|
||||
error( 404 );
|
||||
}
|
||||
$e = $f;
|
||||
$e =~ s/^.*\.//;
|
||||
if( $e eq 'html' )
|
||||
{
|
||||
$t = 'text/html';
|
||||
}
|
||||
elsif( $e eq 'gif' )
|
||||
{
|
||||
$t = 'image/gif';
|
||||
}
|
||||
elsif( $e eq 'jpg' )
|
||||
{
|
||||
$t = 'image/jpeg';
|
||||
}
|
||||
else
|
||||
{
|
||||
$t = 'application/octet-stream';
|
||||
}
|
||||
print <<EOF;
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: $t
|
||||
$server_id
|
||||
|
||||
EOF
|
||||
while( <FILE> )
|
||||
{
|
||||
print;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user