74c99d39c800193f07a881ce98ee4b7065cee6dc
hiram
  Fri Sep 13 10:00:57 2019 -0700
get the warning message out of the warning only message to be used elsewhere and add measureTiming printout to hgGateway refs #23217

diff --git src/hg/lib/botDelay.c src/hg/lib/botDelay.c
index 9b7d1a9..ce5d2af 100644
--- src/hg/lib/botDelay.c
+++ src/hg/lib/botDelay.c
@@ -19,54 +19,67 @@
 #define defaultWarnMs 10000    /* warning at 10 to 20 second delay */
 #define defaultExitMs 20000    /* error 429 Too Many Requests after 20+ second delay */
 
 int botDelayTime(char *host, int port, char *botCheckString)
 /* Figure out suggested delay time for ip address in
  * milliseconds. */
 {
 int sd = netMustConnect(host, port);
 char buf[256];
 netSendString(sd, botCheckString);
 netRecieveString(sd, buf);
 close(sd);
 return atoi(buf);
 }
 
-void botDelayMessage(char *ip, int millis)
-/* Print out message saying why you are stalled. */
+char *botDelayWarningMsg(char *ip, int millis)
+/* return the string for the default botDelay message
+ * not all users of botDelay want the message to go to stderr
+ * return it for their own use case
+ */
 {
 time_t now = time(NULL);
-warn("There is a very high volume of traffic coming from your "
+char *delayMsg = needMem(2048);
+safef(delayMsg, 2048,
+    "There is a very high volume of traffic coming from your "
     "site (IP address %s) as of %s (California time).  So that other "
     "users get a fair share "
     "of our bandwidth, we are putting in a delay of %3.1f seconds "
     "before we service your request.  This delay will slowly "
     "decrease over a half hour as activity returns to normal.  This "
     "high volume of traffic is likely due to program-driven rather than "
     "interactive access, or the submission of queries on a large "
     "number of sequences.  If you are making large batch queries, "
     "please write to our genome@soe.ucsc.edu public mailing list "
     "and inquire about more efficient ways to access our data.  "
     "If you are sharing an IP address with someone who is submitting "
     "large batch queries, we apologize for the "
     "inconvenience. "
     "To use the genome browser functionality from a Unix command line, "
     "please read <a href='http://genome.ucsc.edu/FAQ/FAQdownloads.html#download36'>our FAQ</a> on this topic. "
     "For further help on how to access our data from a command line, "
     "or if "
     "you think this delay is being imposed unfairly, please contact genome-www@soe.ucsc.edu.",
-	    ip, asctime(localtime(&now)), .001*millis);
+    ip, asctime(localtime(&now)), 0.001*millis);
+
+return delayMsg;
+}	/*	char *botDelayWarningMsg(char *ip, int millis)	*/
+
+void botDelayMessage(char *ip, int millis)
+/* Print out message saying why you are stalled. */
+{
+warn("%s", botDelayWarningMsg(ip, millis));
 }
 
 void botTerminateMessage(char *ip, int millis)
 /* Print out message saying why you are terminated. */
 {
 time_t now = time(NULL);
 hUserAbort("There is an exceedingly high volume of traffic coming from your "
        "site (IP address %s) as of %s (California time).  It looks like "
        "a web robot is launching queries quickly, and not even waiting for "
        "the results of one query to finish before launching another query. "
        "/* We cannot service requests from your IP address under */ these "
        "conditions.  (code %d)"
        "To use the genome browser functionality from a Unix command line, "
        "please read <a href='http://genome.ucsc.edu/FAQ/FAQdownloads.html#download36'>our FAQ</a> on this topic. "
        "For further help on how to access our data from a command line, "