diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h index 4c3837b42..319ab48ec 100644 --- a/include/proto/dumpstats.h +++ b/include/proto/dumpstats.h @@ -55,15 +55,6 @@ #define STAT_CLI_O_TAB 8 /* dump tables */ #define STAT_CLI_O_CLR 9 /* clear tables */ -/* status codes (strictly 4 chars) used in the URL to display a message */ -#define STAT_STATUS_UNKN "UNKN" /* an unknown error occured, shouldn't happen */ -#define STAT_STATUS_DONE "DONE" /* the action is successful */ -#define STAT_STATUS_PART "PART" /* the action is partially successful */ -#define STAT_STATUS_NONE "NONE" /* nothing happened (no action chosen or servers state didn't change) */ -#define STAT_STATUS_ERRP "ERRP" /* an error occured due to invalid values in parameters */ -#define STAT_STATUS_EXCD "EXCD" /* an error occured because the buffer couldn't store all data */ -#define STAT_STATUS_DENY "DENY" /* action denied */ - extern struct si_applet http_stats_applet; void stats_io_handler(struct stream_interface *si); diff --git a/include/types/proto_http.h b/include/types/proto_http.h index a7b16aa25..51f321ece 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -258,6 +258,19 @@ enum { ST_ADM_ACTION_ENABLE, }; +/* status codes available for the stats admin page */ +enum { + STAT_STATUS_INIT = 0, + STAT_STATUS_DENY, /* action denied */ + STAT_STATUS_DONE, /* the action is successful */ + STAT_STATUS_ERRP, /* an error occured due to invalid values in parameters */ + STAT_STATUS_EXCD, /* an error occured because the buffer couldn't store all data */ + STAT_STATUS_NONE, /* nothing happened (no action chosen or servers state didn't change) */ + STAT_STATUS_PART, /* the action is partially successful */ + STAT_STATUS_UNKN, /* an unknown error occured, shouldn't happen */ + STAT_STATUS_SIZE +}; + /* This is an HTTP message, as described in RFC2616. It can be either a request * message or a response message. * diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h index 5acbd5743..711394ada 100644 --- a/include/types/stream_interface.h +++ b/include/types/stream_interface.h @@ -149,7 +149,7 @@ struct stream_interface { int px_st; /* STAT_PX_ST* */ unsigned int flags; /* STAT_* */ int iid, type, sid; /* proxy id, type and service id if bounding of stats is enabled */ - const char *st_code; /* pointer to the status code returned by an action */ + int st_code; /* the status code returned by an action */ } stats; struct { struct bref bref; /* back-reference from the session being dumped */ diff --git a/src/dumpstats.c b/src/dumpstats.c index 3f88fc507..dc3ac752b 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -114,6 +114,8 @@ enum { STAT_PX_ST_FIN, }; +extern const char *stat_status_codes[]; + /* This function is called from the session-level accept() in order to instanciate * a new stats socket. It returns a positive value upon success, 0 if the connection * needs to be closed and ignored, or a negative value upon critical failure. @@ -1686,7 +1688,12 @@ static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri) "Content-Type: text/plain\r\n" "Connection: close\r\n" "Location: %s;st=%s", - uri->uri_prefix, si->applet.ctx.stats.st_code); + uri->uri_prefix, + ((si->applet.ctx.stats.st_code > STAT_STATUS_INIT) && + (si->applet.ctx.stats.st_code < STAT_STATUS_SIZE) && + stat_status_codes[si->applet.ctx.stats.st_code]) ? + stat_status_codes[si->applet.ctx.stats.st_code] : + stat_status_codes[STAT_STATUS_UNKN]); chunk_printf(&msg, "\r\n\r\n"); if (buffer_feed_chunk(si->ib, &msg) >= 0) @@ -2023,29 +2030,30 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri) ); if (si->applet.ctx.stats.st_code) { - if (strcmp(si->applet.ctx.stats.st_code, STAT_STATUS_DONE) == 0) { + switch (si->applet.ctx.stats.st_code) { + case STAT_STATUS_DONE: chunk_printf(&msg, "