]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/HTTPD.pm
www_stream: sh-friendly .onion URLs wrapping
[public-inbox.git] / lib / PublicInbox / HTTPD.pm
index b193c9aeeff190abae0c5bee4b363855b61a77fc..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,
@@ -37,7 +38,7 @@ sub new {
                # XXX unstable API!, only GitHTTPBackend needs
                # this to limit git-http-backend(1) parallelism.
                # We also check for the truthiness of this to
-               # detect when to use git_async_cat for slow blobs
+               # detect when to use async paths for slow blobs
                'pi-httpd.async' => \&pi_httpd_async
        );
        bless {