From 7615024f274f67864866c35ce1e3ebb4e448bd63 Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Sat, 15 Sep 2001 21:27:58 +0000 Subject: Changed to using the send_http_message() function so that the HTTP headers are sent properly. --- src/stats.c | 21 +++++++++++++-------- 1 file 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 = \ "%s (%s) stats\r\n" \ "\r\n" \ "

%s (%s) run-time statistics


\r\n" \ @@ -73,14 +72,14 @@ int showstats(struct conn_s *connptr) "Number of refused connections due to high load: %lu\r\n" \ "\r\n\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; } -- cgit v1.2.3