--- deliantra/server/ext/tcp_http.ext 2012/11/06 23:33:15 1.4 +++ deliantra/server/ext/tcp_http.ext 2012/11/07 01:21:27 1.6 @@ -26,6 +26,7 @@ $_[0]->send ("HTTP/1.1 $_[1]\015\012" . "content-length: " . (0 + length $_[2]) . "\015\012" . "access-control-allow-origin: *\015\012" + . $_[0]{ohdr} . "$_[3]\015\012$_[2]"); } @@ -49,10 +50,20 @@ # we ignore headers atm. - $req =~ m%^GET (\S+) HTTP/[0-9.]+\015\012%i + $req =~ m%^GET (\S+) HTTP/([0-9.]+)\015\012%i or return $self->fatal; - my $uri = $1; + my $uri = $1; + my $http = $2; + + if ($http == 1.0) { + if ($req =~ /^connection\s*:\s*keep-alive/mi) { + $self->{ohdr} = "connection: keep-alive\015\012"; + } else { + $self->{ohdr} = "connection: close\015\012"; + delete $self->{rw}; + } + } $uri =~ s%^http://[^/]*%%i; # just in case @@ -104,12 +115,15 @@ push @body, ""; - $self->respond ("200 OK", (join "", @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}"); %$self = (); + } elsif ($uri eq "/") { + $self->respond ("302 hack", "", "location: http://cvs.schmorp.de/deliantra/html5client/client.html\015\012"); + } else { $self->respond ("404 not found"); }