GET /test.html HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030317
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate,compress;q=0.9
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: theme=Tabular
Pragma: no-cache
Cache-Control: no-cache
####
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
my $socket = IO::Socket::INET->new( LocalPort => 7788,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 10,
) or die "$!";
my ( $c, $content, $content_length, $server_type, $date, $text, $html_document,
$header );
$text = &prepare_content;
&serve;
sub serve()
{
while ($c=$socket->accept())
{
print $c "$text\n";
close($c);
}
close($socket);
}
sub prepare_content()
{
$html_document = $ARGV[0];
open(DOCUMENT, $html_document);
my @content = ;
close(DOCUMENT);
$server_type = "Jazserv/1.0";
foreach my $temp (@content)
{ $content = $content . $temp; }
$content_length = length($content);
$date = `date`;
print $content;
$header = "
HTTP/1.1 200 OK
Server: $server_type
ETag: \"\"
Accept-Ranges: bytes
Content-Length: $content_length
Connection: close
Content-Type: text/html; charset=ISO-8859-1
";
return "$header" . "$content";
}