sub handler { capture { MyModule->new->go; } \$out; my ($header, $body) = split /\r\n\r\n/, $out, 2; my $h = HTTP::Headers->new; for my $line (split /\r\n/, $header) { my ($key, $value) = split /: /, $line, 2; $h->header($key, $value); } $h->header('Status' => 200) unless $h->header('Status'); my $status = $h->header('Status'); $h->remove_header('Status'); print 'HTTP/1.1 ' . HTTP::Response->new($status => undef, $h, $body)->as_string("\r\n"); }