/[meteor]/googlecode.com/svn/trunk/Meteor/Document.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /googlecode.com/svn/trunk/Meteor/Document.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25 by knops.gerd, Sun May 20 19:40:53 2007 UTC revision 47 by knops.gerd, Mon Feb 4 21:06:42 2008 UTC
# Line 53  sub serveFileToClient { Line 53  sub serveFileToClient {
53          unless(defined($doc))          unless(defined($doc))
54          {          {
55                  $class->emitHeaderToClient($client,'404 Not Found');                  $class->emitHeaderToClient($client,'404 Not Found');
56                    $::Statistics->{'documents_not_found'}++;
57                    
58                    &::syslog('info','',
59                            'document',
60                            $relPath,
61                            0,
62                            404
63                    );
64                                    
65                  return undef;                  return undef;
66          }          }
# Line 61  sub serveFileToClient { Line 69  sub serveFileToClient {
69                    
70          $::Statistics->{'documents_served'}++;          $::Statistics->{'documents_served'}++;
71                    
72            &::syslog('info','',
73                    'document',
74                    $relPath,
75                    $doc->{'size'},
76                    200
77            );
78            
79          $doc;          $doc;
80  }  }
81    
# Line 68  sub emitHeaderToClient { Line 83  sub emitHeaderToClient {
83          my $self=shift;          my $self=shift;
84          my $client=shift;          my $client=shift;
85          my $status=shift;          my $status=shift;
86            my $length=shift;
87            my $contenttype=shift;
88            $length = 0 unless ($length);
89            $contenttype = "text/html" unless ($contenttype);
90                    
91          my $header=$::CONF{'DocumentHeaderTemplate'};          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";
           
         $header=~s/~([^~]+)~/  
                 if(!defined($1) || $1 eq '')  
                 {  
                         '~';  
                 }  
                 elsif($1 eq 'server')  
                 {  
                         $::PGM;  
                 }  
                 elsif($1 eq 'status')  
                 {  
                         $status;  
                 }  
                 else  
                 {  
                         '';  
                 }  
         /gex;  
92                    
93          $client->write($header);          $client->write($header);
94  }  }
# Line 248  sub newDocument { Line 248  sub newDocument {
248  sub serveTo {  sub serveTo {
249          my $self=shift;          my $self=shift;
250          my $client=shift;          my $client=shift;
251            my $ct = "text/html";
252            if ($self->{'path'} =~/\.(js)$/) {
253                    $ct = "text/javascript";
254            }
255                    
256          $self->emitHeaderToClient($client,'200 OK');          $self->emitHeaderToClient($client,'200 OK',$self->{'size'}, $ct);
257                    
258          $client->write($self->{'document'});          $client->write($self->{'document'});
259    
260  }  }
261    
262  sub path {  sub path {

Legend:
Removed from v.25  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26