summaryrefslogtreecommitdiff
path: root/src/stats.c
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-15 21:27:58 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-15 21:27:58 +0000
commit7615024f274f67864866c35ce1e3ebb4e448bd63 (patch)
tree12bbaced7528f706d82a1365d6e0741314172184 /src/stats.c
parentb7fc58333bddd05c9e0fcf957c372c90de87e045 (diff)
downloadtinyproxy-7615024f274f67864866c35ce1e3ebb4e448bd63.tar.gz
tinyproxy-7615024f274f67864866c35ce1e3ebb4e448bd63.zip
Changed to using the send_http_message() function so that the HTTP headers
are sent properly.
Diffstat (limited to '')
-rw-r--r--src/stats.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/stats.c b/src/stats.c
index 593555b..369d2ae 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1,4 +1,4 @@
-/* $Id: stats.c,v 1.5 2001-09-08 18:58:37 rjkaes Exp $
+/* $Id: stats.c,v 1.6 2001-09-15 21:27:58 rjkaes Exp $
*
* This module handles the statistics for tinyproxy. There are only two
* public API functions. The reason for the functions, rather than just a
@@ -60,8 +60,7 @@ void init_stats(void)
*/
int showstats(struct conn_s *connptr)
{
- static char *msg = "HTTP/1.0 200 OK\r\n" \
- "Content-type: text/html\r\n\r\n" \
+ static char *msg = \
"<html><head><title>%s (%s) stats</title></head>\r\n" \
"<body>\r\n" \
"<center><h2>%s (%s) run-time statistics</h2></center><hr>\r\n" \
@@ -73,14 +72,14 @@ int showstats(struct conn_s *connptr)
"Number of refused connections due to high load: %lu\r\n" \
"</blockquote>\r\n</body></html>\r\n";
- connptr->output_message = safemalloc(MAXBUFFSIZE);
- if (!connptr->output_message) {
- log_message(LOG_CRIT, "Out of memory!");
+ char *message_buffer;
+
+ message_buffer = safemalloc(MAXBUFFSIZE);
+ if (!message_buffer)
return -1;
- }
LOCK();
- snprintf(connptr->output_message, MAXBUFFSIZE, msg,
+ snprintf(message_buffer, MAXBUFFSIZE, msg,
PACKAGE, VERSION, PACKAGE, VERSION,
stats.num_open,
stats.num_reqs,
@@ -89,6 +88,12 @@ int showstats(struct conn_s *connptr)
stats.num_refused);
UNLOCK();
+ if (send_http_message(connptr, 200, "OK", message_buffer) < 0) {
+ safefree(message_buffer);
+ return -1;
+ }
+
+ safefree(message_buffer);
return 0;
}