tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: "Anthony J. Bentley" <anthony@anjbe.name>
Cc: tech@mdocml.bsd.lv, Andreas Voegele <andreas@andreasvoegele.com>
Subject: Re: check environment variable HTTPS in cgi.c
Date: Sat, 18 Mar 2017 17:53:48 +0100	[thread overview]
Message-ID: <20170318165348.GD52684@athene.usta.de> (raw)
In-Reply-To: <90445.1489852127@cathet.us>

Hi Anthony,

Anthony J. Bentley wrote on Sat, Mar 18, 2017 at 09:48:47AM -0600:

> use a relative URI for redirects, as allowed in HTTP/1.1:
> https://tools.ietf.org/html/rfc7231#section-7.1.2

That's actually a fine idea in its own right.
It simplifies things, and i see no downside.

Thanks for the suggestion,
  Ingo


Log Message:
-----------
Simplify: write HTTP 303 redirects with relative locations.
Suggested by bentley@.

Delete the HTTP_HOST configuration variable that is now obsolete.

Modified Files:
--------------
    mdocml:
        cgi.c
        cgi.h.example
        man.cgi.8

Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/cgi.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -Lcgi.c -Lcgi.c -u -p -r1.152 -r1.153
--- cgi.c
+++ cgi.c
@@ -554,8 +554,8 @@ pg_error_internal(void)
 static void
 pg_redirect(const struct req *req, const char *name)
 {
-	printf("Status: 303 See Other\r\n");
-	printf("Location: http://%s/", HTTP_HOST);
+	printf("Status: 303 See Other\r\n"
+	    "Location: /");
 	if (*scriptname != '\0')
 		printf("%s/", scriptname);
 	if (strcmp(req->q.manpath, req->p[0]))
@@ -591,14 +591,15 @@ pg_searchres(const struct req *req, stru
 		 * If we have just one result, then jump there now
 		 * without any delay.
 		 */
-		printf("Status: 303 See Other\r\n");
-		printf("Location: http://%s/%s%s%s/%s",
-		    HTTP_HOST, scriptname,
-		    *scriptname == '\0' ? "" : "/",
-		    req->q.manpath, r[0].file);
-		printf("\r\n"
-		     "Content-Type: text/html; charset=utf-8\r\n"
-		     "\r\n");
+		printf("Status: 303 See Other\r\n"
+		    "Location: /");
+		if (*scriptname != '\0')
+			printf("%s/", scriptname);
+		if (strcmp(req->q.manpath, req->p[0]))
+			printf("%s/", req->q.manpath);
+		printf("%s\r\n"
+		    "Content-Type: text/html; charset=utf-8\r\n\r\n",
+		    r[0].file);
 		return;
 	}
 
Index: cgi.h.example
===================================================================
RCS file: /home/cvs/mdocml/mdocml/cgi.h.example,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lcgi.h.example -Lcgi.h.example -u -p -r1.5 -r1.6
--- cgi.h.example
+++ cgi.h.example
@@ -1,6 +1,5 @@
 /* Example compile-time configuration file for man.cgi(8). */
 
-#define	HTTP_HOST "mdocml.bsd.lv"
 #define	SCRIPT_NAME "cgi-bin/man.cgi"
 #define	MAN_DIR "/man"
 #define	CSS_DIR ""
Index: man.cgi.8
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.cgi.8,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lman.cgi.8 -Lman.cgi.8 -u -p -r1.21 -r1.22
--- man.cgi.8
+++ man.cgi.8
@@ -186,11 +186,6 @@ Otherwise, a leading slash is needed.
 This is used in generated HTML code.
 .It Dv CUSTOMIZE_TITLE
 An ASCII string to be used for the HTML <TITLE> element.
-.It Dv HTTP_HOST
-The FQDN of the (possibly virtual) host the HTTP server is running on.
-This is used for
-.Ic Location:
-headers in HTTP 303 responses.
 .It Dv MAN_DIR
 A file system path to the
 .Nm
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

      reply	other threads:[~2017-03-18 16:53 UTC|newest]

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

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=20170318165348.GD52684@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=andreas@andreasvoegele.com \
    --cc=anthony@anjbe.name \
    --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).