Changed to using the send_http_message() function so that the HTTP headers
are sent properly.
This commit is contained in:
parent
b7fc58333b
commit
7615024f27
21
src/stats.c
21
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
|
* This module handles the statistics for tinyproxy. There are only two
|
||||||
* public API functions. The reason for the functions, rather than just a
|
* 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)
|
int showstats(struct conn_s *connptr)
|
||||||
{
|
{
|
||||||
static char *msg = "HTTP/1.0 200 OK\r\n" \
|
static char *msg = \
|
||||||
"Content-type: text/html\r\n\r\n" \
|
|
||||||
"<html><head><title>%s (%s) stats</title></head>\r\n" \
|
"<html><head><title>%s (%s) stats</title></head>\r\n" \
|
||||||
"<body>\r\n" \
|
"<body>\r\n" \
|
||||||
"<center><h2>%s (%s) run-time statistics</h2></center><hr>\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" \
|
"Number of refused connections due to high load: %lu\r\n" \
|
||||||
"</blockquote>\r\n</body></html>\r\n";
|
"</blockquote>\r\n</body></html>\r\n";
|
||||||
|
|
||||||
connptr->output_message = safemalloc(MAXBUFFSIZE);
|
char *message_buffer;
|
||||||
if (!connptr->output_message) {
|
|
||||||
log_message(LOG_CRIT, "Out of memory!");
|
message_buffer = safemalloc(MAXBUFFSIZE);
|
||||||
|
if (!message_buffer)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
LOCK();
|
LOCK();
|
||||||
snprintf(connptr->output_message, MAXBUFFSIZE, msg,
|
snprintf(message_buffer, MAXBUFFSIZE, msg,
|
||||||
PACKAGE, VERSION, PACKAGE, VERSION,
|
PACKAGE, VERSION, PACKAGE, VERSION,
|
||||||
stats.num_open,
|
stats.num_open,
|
||||||
stats.num_reqs,
|
stats.num_reqs,
|
||||||
@ -89,6 +88,12 @@ int showstats(struct conn_s *connptr)
|
|||||||
stats.num_refused);
|
stats.num_refused);
|
||||||
UNLOCK();
|
UNLOCK();
|
||||||
|
|
||||||
|
if (send_http_message(connptr, 200, "OK", message_buffer) < 0) {
|
||||||
|
safefree(message_buffer);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree(message_buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user