742efb6ff310c75a30cf13088111139cf713b9db
angie
  Tue Feb 23 11:06:52 2016 -0800
Unifying some triplicate code to print an HTTP error 400 response (Bad Request) and exit.

diff --git src/lib/htmshell.c src/lib/htmshell.c
index b1a5807..54a2057 100644
--- src/lib/htmshell.c
+++ src/lib/htmshell.c
@@ -299,30 +299,45 @@
 printf("<script type='text/javascript'>{showWarnBox();"
         "var warnList=document.getElementById('warnList');"
         "warnList.innerHTML += '<li>%s</li>';}</script><!-- ERROR -->\n",encodedMessage); 
                                      // NOTE that "--ERROR --" is needed at the end of this print!!
 freeMem(encodedMessage);
 
 /* Log useful CGI info to stderr */
 logCgiToStderr();
 
 /* write warning/error message to stderr so they get logged. */
 vfprintf(stderr, format, argscp);
 va_end(argscp);
 fflush(stderr);
 }
 
+void htmlVaBadRequestAbort(char *format, va_list args)
+/* Print out an HTTP header 400 status code (Bad Request) and message,
+ * then exit with error.  For use as an errAbort handler. */
+{
+puts("Status: 400\r");
+puts("Content-Type: text/plain; charset=UTF-8\r");
+puts("\r");
+if (format != NULL)
+    {
+    vfprintf(stdout, format, args);
+    fprintf(stdout, "\n");
+    }
+exit(-1);
+}
+
 void htmlAbort()
 /* Terminate HTML file. */
 {
 longjmp(htmlRecover, -1);
 }
 
 void htmlMemDeath()
 {
 errAbort("Out of memory.");
 }
 
 static void earlyWarningHandler(char *format, va_list args)
 /* Write an error message so user can see it before page is really started. */
 {
 static boolean initted = FALSE;