]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/HTTPD.pm
httpd: set psgi.url_scheme to 'https' for TLS listeners
[public-inbox.git] / lib / PublicInbox / HTTPD.pm
index fb683f746a9c988875dd2ee0e141df8d23021d1c..02f424c67138edca6af65835b1f2feb328d3a72d 100644 (file)
@@ -13,7 +13,7 @@ use PublicInbox::Daemon;
 sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) }
 
 sub new {
-       my ($class, $sock, $app) = @_;
+       my ($class, $sock, $app, $client) = @_;
        my $n = getsockname($sock) or die "not a socket: $sock $!\n";
        my ($host, $port) = PublicInbox::Daemon::host_with_port($n);
 
@@ -23,7 +23,8 @@ sub new {
                SCRIPT_NAME => '',
                'psgi.version' => [ 1, 1 ],
                'psgi.errors' => \*STDERR,
-               'psgi.url_scheme' => 'http',
+               'psgi.url_scheme' => $client->can('accept_SSL') ?
+                                       'https' : 'http',
                'psgi.nonblocking' => Plack::Util::TRUE,
                'psgi.streaming' => Plack::Util::TRUE,
                'psgi.run_once'  => Plack::Util::FALSE,