Hi all,

I recently had to deal with somewhat brain-dead web crawler -- it didn't
pay attention to 302 return codes and rejected the body when there was no
<html> tag.

Hence, this mini patch to get the 302 return codes to generate an HTML
meta refresh tag, as well as adding html/head/body tags.

-- DN
Daniel
diff -urN mathopd-1.5p6/src/request.c mathopd-1.5p6.modified//src/request.c
--- mathopd-1.5p6/src/request.c	2011-12-13 21:00:08.000000000 -0800
+++ mathopd-1.5p6.modified//src/request.c	2011-12-13 20:59:52.000000000 -0800
@@ -1548,11 +1548,21 @@
 	p->middle = p->end;
 	if (send_message == 0)
 		return 0;
-	if (pool_print(p, "<title>%s</title>\n<h1>%s</h1>\n", status_line, status_line) == -1)
+	switch (r->status) {
+		case 302:
+			if (pool_print(p, "<html>\n<head>\n<meta http-equiv=\"REFRESH\" content=\"0;url=%s\">\n", r->location) == -1)
+				return -1;
+			break;
+		default:
+			if (pool_print(p, "<html>\n<head>\n") == -1)
+				return -1;
+			break;
+	}
+	if (pool_print(p, "<title>%s</title>\n</head>\n<body>\n<h1>%s</h1>\n", status_line, status_line) == -1)
 		return -1;
 	switch (r->status) {
 	case 302:
-		if (pool_print(p, "This document has moved to URL <a href=\"%s\">%s</a>.\n", r->location, r->location) == -1)
+		if (pool_print(p, "This document has moved to URL <a href=\"%s\">%s</a>.\n</body>\n</html>\n", r->location, r->location) == -1)
 			return -1;
 		break;
 	case 401:

Reply via email to