tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: "Andreas Vögele" <andreas@andreasvoegele.com>
To: tech@mdocml.bsd.lv
Subject: check environment variable HTTPS in cgi.c
Date: Tue, 28 Feb 2017 09:05:09 +0100	[thread overview]
Message-ID: <d6622063-a6e7-6877-eec8-cf3f2a1ca39b@andreasvoegele.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

Hi,

currently the scheme is hard-coded to "http" in cgi.c. The scheme could 
be set to "https" if the environment variable "HTTPS" is set to "on" by 
the web server. See the FastCGI setting in httpd.conf(5).

Regards,
Andreas

[-- Attachment #2: cgi_c_https.diff --]
[-- Type: text/x-patch, Size: 654 bytes --]

--- mdocml-1.14.1/cgi.c.orig	2017-02-21 01:25:20.000000000 +0100
+++ mdocml-1.14.1/cgi.c	2017-02-25 16:28:06.751637253 +0100
@@ -562,9 +562,13 @@
 		 * If we have just one result, then jump there now
 		 * without any delay.
 		 */
+		const char *scheme = "http", *https;
+		if ((https = getenv("HTTPS")) != NULL &&
+		    strcmp(https, "on") == 0)
+			scheme = "https";
 		printf("Status: 303 See Other\r\n");
-		printf("Location: http://%s/%s%s%s/%s",
-		    HTTP_HOST, scriptname,
+		printf("Location: %s://%s/%s%s%s/%s",
+		    scheme, HTTP_HOST, scriptname,
 		    *scriptname == '\0' ? "" : "/",
 		    req->q.manpath, r[0].file);
 		printf("\r\n"

             reply	other threads:[~2017-02-28  8:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28  8:05 Andreas Vögele [this message]
2017-03-18 15:17 ` Ingo Schwarze
2017-03-18 15:48   ` Anthony J. Bentley
2017-03-18 16:53     ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6622063-a6e7-6877-eec8-cf3f2a1ca39b@andreasvoegele.com \
    --to=andreas@andreasvoegele.com \
    --cc=tech@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).