Q:

HTTP::Headers with say

Here is a simple script for a Net::Server::HTTP
#!/usr/bin/env perl

use strict;
use warnings;

use v5.12;

use HTTP::Headers;

use base qw(Net::Server::HTTP);
__PACKAGE__->run(port => 'localhost:8421');

sub process_http_request
{
  my ($self) = @_;
  my $header = HTTP::Headers->new();

  $header->content_type('text/html');

  print $header->as_string() . "\n"; # <- this works
  # say $header->as_string() . "\n"; # <- this doesn't work and I still have to add a newline

  say "<!doctype html>";
  say "<html>";
  say "<head>";
  say "  <title>Test</title>";
  say "</head>";
  say "<body>";
  say "<h1>Test</h1>";
  say "</body>";
  say "</html>";
}

I assumed that by using say I could get round adding a newline, but I have to add it and it breaks the HTTP::Header, by adding another newline to each HTTP field, which doesn't make sense as as_string is suggest it's a string. Can someone please explain what is actually going on here?

A:

The bug seems to be that the software does not properly delegate to Net::Server::TiedHandle's SAY method, only to PRINT. I do not know how to repair this.
I suggest you use Plack for your Web applications instead.
file app.psgi:
my $html = <<'HTML';
<!doctype html>
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
HTML

my $app = sub {
    return [200, [Content_Type => 'text/html'], [$html]];
};

command-line:
plackup --port 8421

