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

Comparing cvsroot/Coro/myhttpd/httpd.pl (file contents):
Revision 1.10 by root, Sat Aug 11 16:34:47 2001 UTC vs.
Revision 1.12 by root, Sat Aug 11 23:10:56 2001 UTC

99 my $self = bless { fh => $fh }, $class; 99 my $self = bless { fh => $fh }, $class;
100 my (undef, $iaddr) = unpack_sockaddr_in $peername 100 my (undef, $iaddr) = unpack_sockaddr_in $peername
101 or $self->err(500, "unable to decode peername"); 101 or $self->err(500, "unable to decode peername");
102 102
103 $self->{remote_addr} = inet_ntoa $iaddr; 103 $self->{remote_addr} = inet_ntoa $iaddr;
104 $self->{time} = $::NOW;
104 105
105 # enter ourselves into various lists 106 # enter ourselves into various lists
106 weaken ($conn{$self->{remote_addr}}{$self*1} = $self); 107 weaken ($conn{$self->{remote_addr}}{$self*1} = $self);
107 108
108 $self; 109 $self;
133 134
134 $res .= $content if defined $content and $self->{method} eq "GET"; 135 $res .= $content if defined $content and $self->{method} eq "GET";
135 136
136 print STDERR "$self->{remote_addr} \"$self->{uri}\" $code ".$hdr->{"Content-Length"}." \"$self->{h}{referer}\"\n";#d# 137 print STDERR "$self->{remote_addr} \"$self->{uri}\" $code ".$hdr->{"Content-Length"}." \"$self->{h}{referer}\"\n";#d#
137 138
139 $self->{written} +=
138 print {$self->{fh}} $res; 140 print {$self->{fh}} $res;
139} 141}
140 142
141sub err { 143sub err {
142 my $self = shift; 144 my $self = shift;
143 my ($code, $msg, $hdr, $content) = @_; 145 my ($code, $msg, $hdr, $content) = @_;
201 203
202 delete $blocked{$ip}; 204 delete $blocked{$ip};
203 } 205 }
204 206
205 if (%{$conn{$ip}} > $::MAX_CONN_IP) { 207 if (%{$conn{$ip}} > $::MAX_CONN_IP) {
206 $self->slog("blocked ip $ip"); 208 $self->slog(2, "blocked ip $ip");
207 $self->err_blocked; 209 $self->err_blocked;
208 } 210 }
209 211
210 $req =~ /^(?:\015\012)? 212 $req =~ /^(?:\015\012)?
211 (GET|HEAD) \040+ 213 (GET|HEAD) \040+
398 400
399satisfiable: 401satisfiable:
400 # check for segmented downloads 402 # check for segmented downloads
401 if ($l && $::NO_SEGMENTED) { 403 if ($l && $::NO_SEGMENTED) {
402 if (%{$uri{$self->{uri}}} > 1) { 404 if (%{$uri{$self->{uri}}} > 1) {
403 $self->slog("segmented download refused\n");
404 $self->err(400, "segmented downloads are not allowed"); 405 $self->err(400, "segmented downloads are not allowed");
405 } 406 }
406 } 407 }
407 408
408 $hdr->{"Content-Range"} = "bytes $l-$h/$length"; 409 $hdr->{"Content-Range"} = "bytes $l-$h/$length";
432 433
433 $h -= $l - 1; 434 $h -= $l - 1;
434 435
435 while ($h > 0) { 436 while ($h > 0) {
436 $h -= sysread $fh, $buf, $h > $::BUFSIZE ? $::BUFSIZE : $h; 437 $h -= sysread $fh, $buf, $h > $::BUFSIZE ? $::BUFSIZE : $h;
437 $self->{fh}->syswrite($buf) 438 my $w = $self->{fh}->syswrite($buf)
438 or last; 439 or last;
440 $::written += $w;
441 $self->{written} += $w;
439 } 442 }
440 } 443 }
441 444
442 close $fh; 445 close $fh;
443} 446}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines