source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Simplify: write HTTP 303 redirects with relative locations.
@ 2017-03-18 16:48 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-03-18 16:48 UTC (permalink / raw)
  To: source

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 source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-18 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 16:48 mdocml: Simplify: write HTTP 303 redirects with relative locations schwarze

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).