
HTTP404
Deleted
Mar 12, 2001, 10:14 AM
Post #1 of 1
(105 views)
|
|
Perl web server project
|
Can't Post
|
|
this is simple web server written in perl but has 1 problem #!/usr/local/bin/perl use IO::Socket; my $listening_socket =IO::Socket::INET->new(Proto => 'tcp', LocalPort => 25123, Listen => 2, Reuse => 1) or die $!; my $i=0; while(1){ $socket = $listening_socket->accept; $socket->recv($line,512); while($line=~ /\[\n]+/i){ $socket->recv($line,512); } open(FILE, "C:\\act\\index.html"); $socket->send("HTTP 200 OK\r\n"); $socket->send("Server: Perl-HTTPD\r\n"); $socket->send("Content-type:text/html\r\n"); $socket->send("Content-length: 948\r\n\n"); while(<FILE>){ if($_ eq '\n'){ $socket->send("\n\r"); }else{ $socket->send($_); } } foreach $x(@line){ print "$line[$x]"; } $socket->close; } when u telnet to it and press any key it already displays content i want to use web browser with it, as web browsers use \n\n (2 new lines) at end of header how can i make it understand it
|