Sadly, I would have thought that the correct solution is the
following, at the end, once we have $server:
$server->cgi_init(
sub {
require CGI;
CGI::initialize_globals();
CGI->import(qw(-utf8));
});
This is based on the documentation of HTTP::Server::Simple::CGI, and
skimming its source code, and the documentation of the use pragma, and
the pseudo code in its documentation. The workaround of setting
$CGI::PARAM_UTF8 directly is based on reading the CGI.pm source code.
This is definitely a hack.
Trying a different solution. The existing solution only worked for
relative paths in $DataDir. Now we check whether $DataDir starts with /
or ./ and only prepend a ./ if it does not.