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.15 by root, Mon Jan 9 16:23:53 2017 UTC vs.
Revision 1.16 by root, Wed Jan 11 12:10:25 2017 UTC

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 $_[1] =~ /^\x89PNG/; 46 return "content-type: image/png\015\012" if $_[1] =~ /^\x89PNG/;
47 return "content-type: image/jpeg\015\012" if $_[1] =~ /^......JFIF/s; 47 return "content-type: image/jpeg\015\012" if $_[1] =~ /^......JFIF/s;
48 return "content-type: audio/wav\015\012" if $_[1] =~ /^RIFF/; 48 return "content-type: audio/wav\015\012" if $_[1] =~ /^RIFF/;
49 return "content-type: audio/ogg\015\012" if $_[1] =~ /^OggS/; 49 return "content-type: audio/ogg\015\012" if $_[1] =~ /^OggS/;
50 return "content-type: text/html\015\012" if $_[1] =~ /^</;
51 return "content-type: text/css\015\012" if $_[0] =~ /\.css$/; 50 return "content-type: text/css; charset=utf-8\015\012" if $_[0] =~ /\.css$/;
51 return "content-type: application/javascript; charset=utf-8\015\012" if $_[0] =~ /\.js$/;
52 return "content-type: text/html; charset=utf-8\015\012" if $_[1] =~ /^</;
52 53
53 "content-type: text/plain\015\012" 54 "content-type: text/plain; charset=utf-8\015\012"
54} 55}
55 56
56sub handle_con { 57sub handle_con {
57 my ($self) = @_; 58 my ($self) = @_;
58 59
134 (my $meta, $data) = unpack "(w/a*)*", $data 135 (my $meta, $data) = unpack "(w/a*)*", $data
135 if $type & 1; 136 if $type & 1;
136 137
137 if ($want_meta) { 138 if ($want_meta) {
138 if ($type & 1) { 139 if ($type & 1) {
139 $self->respond ("200 OK", $meta, "content-type: text/plain\015\012" . $cache_headers); 140 $self->respond ("200 OK", $meta, "content-type: text/plain; charset=utf-8\015\012" . $cache_headers);
140 } else { 141 } else {
141 $self->respond ("404 type $type has no metadata"); 142 $self->respond ("404 type $type has no metadata");
142 } 143 }
143 } else { 144 } else {
144 $self->respond ("200 OK", $data, (content_type $uri, $data) . $cache_headers); 145 $self->respond ("200 OK", $data, (content_type $uri, $data) . $cache_headers);
186 187
187 push @body, "</body></html>"; 188 push @body, "</body></html>";
188 189
189 my $body = join "", @body; 190 my $body = join "", @body;
190 utf8::encode $body; 191 utf8::encode $body;
191 $self->respond ("200 OK", $body, "content-type: text/html\015\012"); 192 $self->respond ("200 OK", $body, "content-type: text/html; charset=utf-8\015\012");
192 193
193 } else { 194 } else {
194 $self->respond ("404 not found"); 195 $self->respond ("404 not found");
195 } 196 }
196 197

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines