#!/opt/perl/bin/perl
use AnyEvent;
use BS::HTTPD;

my $cvar = AnyEvent->condvar;

my $httpd = BS::HTTPD->new (port => 9090);

$httpd->reg_cb (
   _ => sub {
      my ($httpd, $url, $headers) = @_;

      $httpd->o ("<html><body><h1>Testing return types...</h1>");
      $httpd->o ("<img src=\"/image/bshttp.png\" />");
      $httpd->o ("</body></html>");

      () # !
   },
   '_image_bshttp.png' => sub {
      open IMG, 'bshttp.png'
         or return [404, 'not found', { 'Content-Type' => 'text/plain' }, 'Fail!'];
      { content => [ 'image/png', do { local $/; <IMG> } ] }
   },
);

$cvar->wait;
