CC: | cpan [...] iotti.biz |
Subject: | HTTP::Server::Simple::CGI::PreFork and HTTPS |
I'm using HTTP::Server::Simple::CGI::PreFork with HTTPS. I noticed that CGI.pm fails to recognize I'm using HTTPS and so when I call url() to construct a link to some document in my service, it gives me http:// and not https:// links. I found that this is due to the lack of the HTTPS environment variable, which would also be required by the CGI specification. CGI.pm uses this variable to recognize when the underlying protocol is HTTPS and not HTTP.
I solved my problem adding the variable:
--- /usr/share/perl5/vendor_perl/HTTP/Server/Simple/CGI/PreFork.pm.orig 2016-10-09 18:47:58.000000000 +0200
+++ /usr/share/perl5/vendor_perl/HTTP/Server/Simple/CGI/PreFork.pm 2016-10-10 06:59:50.402388292 +0200
@@ -321,6 +321,7 @@
require HTTP::Server::Simple::CGI;
*{"$pkg\::post_accept"} = sub {
HTTP::Server::Simple::CGI::Environment->setup_environment;
+ $config{usessl} and $ENV{'HTTPS'} = 'on'; # Required by CGI spec. Also needed for CGI.pm to return 'on' (and not undef) in https() and to return https:// and not http:// links in url().
# $self->SUPER::post_accept uses the wrong super package
$server->can('post_accept')->(@_);
};
I'm not 100% sure if it is the most appropriate place to do this, I only know it works. I would kindly ask if the maintainer may take a look at it and in case, include in a future release.
Thank you, best regards
Luigi