ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/httpd.pl
(Generate patch)

Comparing Coro/myhttpd/httpd.pl (file contents):
Revision 1.26 by root, Sun Aug 19 22:59:35 2001 UTC vs.
Revision 1.27 by root, Sun Aug 19 23:57:52 2001 UTC

9# at least on my machine, this thingy serves files 9# at least on my machine, this thingy serves files
10# quite a bit faster than apache, ;) 10# quite a bit faster than apache, ;)
11# and quite a bit slower than thttpd :( 11# and quite a bit slower than thttpd :(
12 12
13$SIG{PIPE} = 'IGNORE'; 13$SIG{PIPE} = 'IGNORE';
14 14
15our $accesslog;
16
17if ($ACCESS_LOG) {
18 use IO::Handle;
19 open $accesslog, ">>$ACCESS_LOG"
20 or die "$ACCESS_LOG: $!";
21 $accesslog->autoflush(1);
22}
23
15sub slog { 24sub slog {
16 my $level = shift; 25 my $level = shift;
17 my $format = shift; 26 my $format = shift;
18 printf "---: $format\n", @_; 27 printf "---: $format\n", @_;
19} 28}
151 } 160 }
152 $res .= "\015\012"; 161 $res .= "\015\012";
153 162
154 $res .= $content if defined $content and $self->{method} ne "HEAD"; 163 $res .= $content if defined $content and $self->{method} ne "HEAD";
155 164
156 print STDERR "$self->{remote_addr} \"$self->{uri}\" $code ".$hdr->{"Content-Length"}." \"$self->{h}{referer}\"\n"; 165 my $log = "$self->{remote_addr} \"$self->{uri}\" $code ".$hdr->{"Content-Length"}." \"$self->{h}{referer}\"\n";
166
167 print $accesslog $log if $accesslog;
168 print STDERR $log;
157 169
158 $self->{written} += 170 $self->{written} +=
159 print {$self->{fh}} $res; 171 print {$self->{fh}} $res;
160} 172}
161 173
188 "Retry-After" => $::BLOCKTIME, 200 "Retry-After" => $::BLOCKTIME,
189 "Warning" => "Please do NOT retry, you have been blocked", 201 "Warning" => "Please do NOT retry, you have been blocked",
190 "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked\"", 202 "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked\"",
191 }, 203 },
192 <<EOF); 204 <<EOF);
193<html><p> 205<html>
206<head>
207<title>Too many connections</title>
208</head>
209<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
210
194You have been blocked because you opened too many connections. You 211<p>You have been blocked because you opened too many connections. You
195may retry at</p> 212may retry at</p>
196 213
197 <p><blockquote>$time.</blockquote></p> 214 <p><blockquote>$time.</blockquote></p>
198 215
199<p>Until then, each new access will renew the block. You might want to have a 216<p>Until then, each new access will renew the block. You might want to have a
200look at the <a href="http://www.goof.com/pcg/marc/animefaq.html">FAQ</a>.</p> 217look at the <a href="http://www.goof.com/pcg/marc/animefaq.html">FAQ</a>.</p>
201</html> 218
219</body></html>
202EOF 220EOF
203} 221}
204 222
205sub handle { 223sub handle {
206 my $self = shift; 224 my $self = shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines