--- deliantra/server/ext/tcp_http.ext 2012/11/06 01:25:48 1.1
+++ deliantra/server/ext/tcp_http.ext 2012/11/06 21:50:36 1.3
@@ -1,8 +1,6 @@
#! perl # optional depends=tcp
-# http server on base port
-
-use Coro::AnyEvent;
+# http server
sub send {
my $self = $_[0];
@@ -60,7 +58,7 @@
cf::debug "HTTP GET: $self->{id} $uri";
- if ($uri =~ m%^/(M?)([0-9a-f]+)$%) { # faces
+ if ($uri =~ m%^/([0-9a-f]+)(M?)$%) { # faces
my $want_meta = $1;
my $idx = $cf::FACEHASH{pack "H*", $2};
@@ -89,24 +87,24 @@
}
} elsif ($uri eq "/debug") { # for debugging
- my $body = "
";
+ my @body = "";
for my $type (6, 5, 4, 3, 2, 1, 0) {
- $body .= "$type
";
+ push @body, "$type
";
for (1 .. cf::face::faces_size - 1) {
next if $type != cf::face::get_type $_;
my $name = cf::face::get_name $_;
my $id = unpack "H*", cf::face::get_chksum $_, 1;
- $body .= "$_ $name ($id)";
- $body .= " (meta)" if $type & 1;
- $body .= "
";
+ push @body, "$_ $name ($id)";
+ push @body, " (meta)" if $type & 1;
+ push @body, "
";
}
}
- $body .= "";
+ push @body, "";
- $self->respond ("200 OK", $body, "Content-Type: text/html\015\012");
+ $self->respond ("200 OK", (join "", @body), "Content-Type: text/html\015\012");
} elsif ($uri eq "/ws" && defined &ext::ws::server) {
&ext::ws::server ($self->{id}, $self->{fh}, "$req\015\012\015\012$self->{rbuf}");
@@ -120,7 +118,7 @@
our $DETECTOR = ext::tcp::register http => 64, sub {
# regex avoids conflict with websockets, which use /ws
- m{^(?:(?i)GET|HEAD|OPTIONS) \ (?: [^/] | /[^w] | /w[^s] /ws[^\ ] ) }x
+ m{^(?i:GET|HEAD|OPTIONS) \ (?! (?i:http://[^/]+)? /ws \ ) }x
}, sub {
my $self = bless {
id => $_[0],