ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/tcp_http.ext
(Generate patch)

Comparing deliantra/server/ext/tcp_http.ext (file contents):
Revision 1.14 by root, Mon Nov 12 01:06:38 2012 UTC vs.
Revision 1.15 by root, Mon Jan 9 16:23:53 2017 UTC

40} 40}
41 41
42my $cache_headers = "cache-control: max-age=8640000\015\012" 42my $cache_headers = "cache-control: max-age=8640000\015\012"
43 . "etag: \"0\"\015\012"; 43 . "etag: \"0\"\015\012";
44 44
45sub content_type { 45sub content_type($$) {
46 return "content-type: image/png\015\012" if $_[0] =~ /^\x89PNG/; 46 return "content-type: image/png\015\012" if $_[1] =~ /^\x89PNG/;
47 return "content-type: image/jpeg\015\012" if $_[0] =~ /^......JFIF/s; 47 return "content-type: image/jpeg\015\012" if $_[1] =~ /^......JFIF/s;
48 return "content-type: audio/wav\015\012" if $_[0] =~ /^RIFF/; 48 return "content-type: audio/wav\015\012" if $_[1] =~ /^RIFF/;
49 return "content-type: audio/ogg\015\012" if $_[0] =~ /^OggS/; 49 return "content-type: audio/ogg\015\012" if $_[1] =~ /^OggS/;
50 return "content-type: text/html\015\012" if $_[0] =~ /^</; 50 return "content-type: text/html\015\012" if $_[1] =~ /^</;
51 return "content-type: text/css\015\012" if $_[0] =~ /\.css$/;
51 52
52 "content-type: text/plain\015\012" 53 "content-type: text/plain\015\012"
53} 54}
54 55
55sub handle_con { 56sub handle_con {
138 $self->respond ("200 OK", $meta, "content-type: text/plain\015\012" . $cache_headers); 139 $self->respond ("200 OK", $meta, "content-type: text/plain\015\012" . $cache_headers);
139 } else { 140 } else {
140 $self->respond ("404 type $type has no metadata"); 141 $self->respond ("404 type $type has no metadata");
141 } 142 }
142 } else { 143 } else {
143 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers); 144 $self->respond ("200 OK", $data, (content_type $uri, $data) . $cache_headers);
144 } 145 }
145 146
146 } elsif (my $idx = (cf::face::find "res/http$uri") || (cf::face::find "res/http${uri}index.html")) { 147 } elsif (my $idx = (cf::face::find "res/http$uri") || (cf::face::find "res/http${uri}index.html")) {
147 # TODO: use etag (shudder) 148 # TODO: use etag (shudder)
148 my $data = cf::face::get_data $idx; 149 my $data = cf::face::get_data $idx;
149 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers); 150 $self->respond ("200 OK", $data, (content_type $uri, $data) . $cache_headers);
150 151
151 } elsif (cf::face::find "res/http$uri/index.html") { 152 } elsif (cf::face::find "res/http$uri/index.html") {
152 $self->respond ("302 dirslash", "", "location: $uri/\015\012"); 153 $self->respond ("302 dirslash", "", "location: $uri/\015\012");
153 154
154 } elsif ($uri eq "/debug") { # for debugging 155 } elsif ($uri eq "/debug") { # for debugging

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines