[MINOR] add support for "stats refresh <interval>"

Sometimes it may be desirable to automatically refresh the
stats page. Most browsers support the "Refresh:" header with
an interval in seconds. Specifying "stats refresh xxx" will
automatically add this header.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 967b9ca..783e189 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1040,6 +1040,16 @@
 				Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
 				return -1;
 			}
+		} else if (!strcmp(args[1], "refresh")) {
+			int interval = atoi(args[2]);
+			
+			if (interval < 0) {
+				Alert("parsing [%s:%d] : 'refresh' needs a positive interval in seconds.\n", file, linenum);
+				return -1;
+			} else if (!stats_set_refresh(&curproxy->uri_auth, interval)) {
+				Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
+				return -1;
+			}
 		} else if (!strcmp(args[1], "auth")) {
 			if (*(args[2]) == 0) {
 				Alert("parsing [%s:%d] : 'auth' needs a user:password account.\n", file, linenum);
diff --git a/src/proto_http.c b/src/proto_http.c
index 1042081..8ebdc61 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3451,8 +3451,13 @@
 			     "HTTP/1.0 200 OK\r\n"
 			     "Cache-Control: no-cache\r\n"
 			     "Connection: close\r\n"
-			     "Content-Type: text/html\r\n"
-			     "\r\n");
+			     "Content-Type: text/html\r\n");
+
+		if (s->be->uri_auth->refresh > 0)
+			chunk_printf(&msg, sizeof(trash), "Refresh: %d\r\n",
+				     s->be->uri_auth->refresh);
+
+		chunk_printf(&msg, sizeof(trash), "\r\n");
 
 		s->txn.status = 200;
 		client_retnclose(s, &msg); // send the start of the response.
diff --git a/src/uri_auth.c b/src/uri_auth.c
index f666c0d..f5f90af 100644
--- a/src/uri_auth.c
+++ b/src/uri_auth.c
@@ -1,7 +1,7 @@
 /*
  * URI-based user authentication using the HTTP basic method.
  *
- * Copyright 2006 Willy Tarreau <w@1wt.eu>
+ * Copyright 2006-2007 Willy Tarreau <w@1wt.eu>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -114,6 +114,19 @@
 }
 
 /*
+ * Returns a default uri_auth with the <refresh> refresh interval.
+ * Uses the pointer provided if not NULL and not initialized.
+ */
+struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval)
+{
+	struct uri_auth *u;
+	
+	if ((u = stats_check_init_uri_auth(root)) != NULL)
+		u->refresh = interval;
+	return u;
+}
+
+/*
  * Returns a default uri_auth with a <user:passwd> entry added to the list of
  * authorized users. If a matching entry is found, no update will be performed.
  * Uses the pointer provided if not NULL and not initialized.
@@ -204,3 +217,9 @@
 	return NULL;
 }
 
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */