45 |
my $class=shift; |
my $class=shift; |
46 |
my $relPath=shift; |
my $relPath=shift; |
47 |
my $client=shift; |
my $client=shift; |
48 |
|
|
49 |
&::syslog('debug',"Meteor::Document: Request received for '%s'",$relPath); |
&::syslog('debug',"Meteor::Document: Request received for '%s'",$relPath); |
50 |
|
|
51 |
my $doc=$class->documentForPath($relPath); |
my $doc=$class->documentForPath($relPath); |
59 |
|
|
60 |
$doc->serveTo($client); |
$doc->serveTo($client); |
61 |
|
|
62 |
|
$::Statistics->{'documents_served'}++; |
63 |
|
|
64 |
$doc; |
$doc; |
65 |
} |
} |
66 |
|
|
68 |
my $self=shift; |
my $self=shift; |
69 |
my $client=shift; |
my $client=shift; |
70 |
my $status=shift; |
my $status=shift; |
71 |
|
my $length=shift; |
72 |
|
my $contenttype=shift; |
73 |
|
$length = 0 unless ($length); |
74 |
|
$contenttype = "text/html" unless ($contenttype); |
75 |
|
|
76 |
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; |
|
77 |
|
|
78 |
$client->write($header); |
$client->write($header); |
79 |
} |
} |
233 |
sub serveTo { |
sub serveTo { |
234 |
my $self=shift; |
my $self=shift; |
235 |
my $client=shift; |
my $client=shift; |
236 |
|
my $ct = "text/html"; |
237 |
|
if ($self->{'path'} =~/\.(js)$/) { |
238 |
|
$ct = "text/javascript"; |
239 |
|
} |
240 |
|
|
241 |
$self->emitHeaderToClient($client,'200 OK'); |
$self->emitHeaderToClient($client,'200 OK',$self->{'size'}, $ct); |
242 |
|
|
243 |
$client->write($self->{'document'}); |
$client->write($self->{'document'}); |
244 |
|
|
245 |
} |
} |
246 |
|
|
247 |
sub path { |
sub path { |