--- googlecode.com/svn/trunk/Meteor/Document.pm 2006/12/14 16:58:18 12 +++ googlecode.com/svn/trunk/Meteor/Document.pm 2008/02/01 21:54:05 38 @@ -45,7 +45,7 @@ my $class=shift; my $relPath=shift; my $client=shift; - + &::syslog('debug',"Meteor::Document: Request received for '%s'",$relPath); my $doc=$class->documentForPath($relPath); @@ -53,12 +53,15 @@ unless(defined($doc)) { $class->emitHeaderToClient($client,'404 Not Found'); + $::Statistics->{'documents_not_found'}++; return undef; } $doc->serveTo($client); + $::Statistics->{'documents_served'}++; + $doc; } @@ -66,27 +69,12 @@ my $self=shift; my $client=shift; my $status=shift; + my $length=shift; + my $contenttype=shift; + $length = 0 unless ($length); + $contenttype = "text/html" unless ($contenttype); - my $header=$::CONF{'DocumentHeaderTemplate'}; - - $header=~s/~([^~]+)~/ - if(!defined($1) || $1 eq '') - { - '~'; - } - elsif($1 eq 'server') - { - $::PGM; - } - elsif($1 eq 'status') - { - $status; - } - else - { - ''; - } - /gex; + my $header="HTTP/1.1 ".$status."\r\nServer: ".$::PGM."\r\nContent-Type: ".$contenttype."; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\nContent-length: ".$length."\r\n\r\n"; $client->write($header); } @@ -246,10 +234,15 @@ sub serveTo { my $self=shift; my $client=shift; + my $ct = "text/html"; + if ($self->{'path'} =~/\.(js)$/) { + $ct = "text/javascript"; + } - $self->emitHeaderToClient($client,'200 OK'); + $self->emitHeaderToClient($client,'200 OK',$self->{'size'}, $ct); $client->write($self->{'document'}); + } sub path {