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.6 by root, Wed Nov 7 01:21:27 2012 UTC vs.
Revision 1.7 by root, Thu Nov 8 03:37:42 2012 UTC

36sub content_type { 36sub content_type {
37 return "content-type: image/png\015\012" if $_[0] =~ /^\x89PNG/; 37 return "content-type: image/png\015\012" if $_[0] =~ /^\x89PNG/;
38 return "content-type: image/jpeg\015\012" if $_[0] =~ /^......JFIF/s; 38 return "content-type: image/jpeg\015\012" if $_[0] =~ /^......JFIF/s;
39 return "content-type: audio/wav\015\012" if $_[0] =~ /^RIFF/; 39 return "content-type: audio/wav\015\012" if $_[0] =~ /^RIFF/;
40 return "content-type: audio/ogg\015\012" if $_[0] =~ /^OggS/; 40 return "content-type: audio/ogg\015\012" if $_[0] =~ /^OggS/;
41 return "content-type: text/html\015\012" if $_[0] =~ /^</;
41 42
42 "content-type: text/plain\015\012" 43 "content-type: text/plain\015\012"
43} 44}
44 45
45sub handle_req { 46sub handle_req {
95 } 96 }
96 } else { 97 } else {
97 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers); 98 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers);
98 } 99 }
99 100
101 } elsif (my $idx = (cf::face::find "res/http$uri") || (cf::face::find "res/http${uri}index.html")) {
102 my $data = cf::face::get_data $idx, 1;
103 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers);
104
105 } elsif (cf::face::find "res/http$uri/index.html") {
106 $self->respond ("302 dirslash", "", "location: $uri/\015\012");
107
100 } elsif ($uri eq "/debug") { # for debugging 108 } elsif ($uri eq "/debug") { # for debugging
101 my @body = "<html><body>"; 109 my @body = "<html><body>";
102 110
103 for my $type (6, 5, 4, 3, 2, 1, 0) { 111 for my $type (6, 5, 4, 3, 2, 1, 0) {
104 push @body, "<h1>$type</h1>"; 112 push @body, "<h1>$type</h1>";
118 $self->respond ("200 OK", (join "", @body), "content-type: text/html\015\012"); 126 $self->respond ("200 OK", (join "", @body), "content-type: text/html\015\012");
119 } elsif ($uri eq "/ws" && defined &ext::ws::server) { 127 } elsif ($uri eq "/ws" && defined &ext::ws::server) {
120 &ext::ws::server ($self->{id}, $self->{fh}, "$req\015\012\015\012$self->{rbuf}"); 128 &ext::ws::server ($self->{id}, $self->{fh}, "$req\015\012\015\012$self->{rbuf}");
121 129
122 %$self = (); 130 %$self = ();
123
124 } elsif ($uri eq "/") {
125 $self->respond ("302 hack", "", "location: http://cvs.schmorp.de/deliantra/html5client/client.html\015\012");
126 131
127 } else { 132 } else {
128 $self->respond ("404 not found"); 133 $self->respond ("404 not found");
129 } 134 }
130 } 135 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines