The stats now wait until after the client has finished sending all its
headers before sending the HTTP response back. This should be more standards compliant.
This commit is contained in:
parent
1691feb9bb
commit
60f0a86c75
@ -1,5 +1,9 @@
|
||||
2002-04-18 Robert James Kaes <rjkaes@flarenet.com>
|
||||
|
||||
* src/reqs.c: Added a new show_stats field in the conn_s structure
|
||||
so that we will process the client's headers properly before
|
||||
trying to send a HTTP response back.
|
||||
|
||||
* src/sock.c (getpeer_string): Removed the hstrerror() call since
|
||||
it's not supported on all machines, and it's not really needed
|
||||
anyway.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: conns.c,v 1.9 2002-04-15 02:07:27 rjkaes Exp $
|
||||
/* $Id: conns.c,v 1.10 2002-04-18 21:43:52 rjkaes Exp $
|
||||
*
|
||||
* Create and free the connection structure. One day there could be
|
||||
* other connnection related tasks put here, but for now the header
|
||||
@ -62,6 +62,7 @@ initialize_conn(int client_fd)
|
||||
connptr->error_number = -1;
|
||||
|
||||
connptr->connect_method = FALSE;
|
||||
connptr->show_stats = FALSE;
|
||||
|
||||
connptr->protocol.major = connptr->protocol.minor = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: conns.h,v 1.8 2002-04-15 02:07:27 rjkaes Exp $
|
||||
/* $Id: conns.h,v 1.9 2002-04-18 21:43:53 rjkaes Exp $
|
||||
*
|
||||
* See 'conns.c' for a detailed description.
|
||||
*
|
||||
@ -34,6 +34,7 @@ struct conn_s {
|
||||
char *request_line;
|
||||
|
||||
bool_t connect_method;
|
||||
bool_t show_stats;
|
||||
|
||||
/* Store the error response if there is one */
|
||||
char *error_string;
|
||||
|
18
src/reqs.c
18
src/reqs.c
@ -1,4 +1,4 @@
|
||||
/* $Id: reqs.c,v 1.62 2002-04-18 17:58:52 rjkaes Exp $
|
||||
/* $Id: reqs.c,v 1.63 2002-04-18 21:43:53 rjkaes Exp $
|
||||
*
|
||||
* This is where all the work in tinyproxy is actually done. Incoming
|
||||
* connections have a new thread created for them. The thread then
|
||||
@ -430,10 +430,9 @@ process_request(struct conn_s *connptr)
|
||||
*/
|
||||
if (config.stathost && strcmp(config.stathost, request->host) == 0) {
|
||||
log_message(LOG_NOTICE, "Request for the stathost.");
|
||||
connptr->show_stats = TRUE;
|
||||
|
||||
free_request_struct(request);
|
||||
|
||||
showstats(connptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -716,10 +715,11 @@ process_client_headers(struct conn_s *connptr)
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't send headers if there's already an error, or if this was
|
||||
* a CONNECT method (unless upstream proxy is in use.)
|
||||
* Don't send headers if there's already an error, if the request was
|
||||
* a stats request, or if this was a CONNECT method (unless upstream
|
||||
* proxy is in use.)
|
||||
*/
|
||||
if (connptr->server_fd == -1
|
||||
if (connptr->server_fd == -1 || connptr->show_stats
|
||||
|| (connptr->connect_method && !UPSTREAM_CONFIGURED())) {
|
||||
log_message(LOG_INFO, "Not sending client headers to remote machine");
|
||||
hashmap_delete(hashofheaders);
|
||||
@ -1143,7 +1143,7 @@ handle_connection(int fd)
|
||||
|
||||
request = process_request(connptr);
|
||||
if (!request) {
|
||||
if (!connptr->error_string) {
|
||||
if (!connptr->error_string && !connptr->show_stats) {
|
||||
update_stats(STAT_BADCONN);
|
||||
destroy_conn(connptr);
|
||||
return;
|
||||
@ -1184,6 +1184,10 @@ handle_connection(int fd)
|
||||
send_http_error_message(connptr);
|
||||
destroy_conn(connptr);
|
||||
return;
|
||||
} else if (connptr->show_stats) {
|
||||
showstats(connptr);
|
||||
destroy_conn(connptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connptr->connect_method || UPSTREAM_CONFIGURED()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user