mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MEDIUM: snapshot: implement a show() callback and use it for HTTP
The HTTP dumps are now configurable in the code : "show errors" now calls a protocol-specific function to emit the decoded output. For now only HTTP is implemented.
This commit is contained in:
parent
0b5b480594
commit
7ccdd8dad9
@ -239,6 +239,7 @@ struct error_snapshot {
|
|||||||
unsigned int ev_id; /* event number (counter incremented for each capture) */
|
unsigned int ev_id; /* event number (counter incremented for each capture) */
|
||||||
/* @68: 4 bytes hole here */
|
/* @68: 4 bytes hole here */
|
||||||
struct sockaddr_storage src; /* client's address */
|
struct sockaddr_storage src; /* client's address */
|
||||||
|
void (*show)(struct buffer *, const struct error_snapshot *); /* dump function */
|
||||||
|
|
||||||
/**** protocol-specific part ****/
|
/**** protocol-specific part ****/
|
||||||
union error_snapshot_ctx ctx;
|
union error_snapshot_ctx ctx;
|
||||||
|
@ -8008,6 +8008,22 @@ int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct pr
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append the description of what is present in error snapshot <es> into <out>.
|
||||||
|
* The description must be small enough to always fit in a trash. The output
|
||||||
|
* buffer may be the trash so the trash must not be used inside this function.
|
||||||
|
*/
|
||||||
|
void http_show_error_snapshot(struct buffer *out, const struct error_snapshot *es)
|
||||||
|
{
|
||||||
|
chunk_appendf(&trash,
|
||||||
|
" stream #%d, stream flags 0x%08x, tx flags 0x%08x\n"
|
||||||
|
" HTTP msg state %s(%d), msg flags 0x%08x\n"
|
||||||
|
" HTTP chunk len %lld bytes, HTTP body len %lld bytes, channel flags 0x%08x :\n",
|
||||||
|
es->ctx.http.sid, es->ctx.http.s_flags, es->ctx.http.t_flags,
|
||||||
|
h1_msg_state_str(es->ctx.http.state), es->ctx.http.state,
|
||||||
|
es->ctx.http.m_flags, es->ctx.http.m_clen,
|
||||||
|
es->ctx.http.m_blen, es->ctx.http.b_flags);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Capture a bad request or response and archive it in the proxy's structure.
|
* Capture a bad request or response and archive it in the proxy's structure.
|
||||||
* By default it tries to report the error position as msg->err_pos. However if
|
* By default it tries to report the error position as msg->err_pos. However if
|
||||||
@ -8063,6 +8079,7 @@ void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, st
|
|||||||
es->buf_ofs = 0;
|
es->buf_ofs = 0;
|
||||||
|
|
||||||
/* http-specific part now */
|
/* http-specific part now */
|
||||||
|
es->show = http_show_error_snapshot;
|
||||||
es->ctx.http.sid = s->uniq_id;
|
es->ctx.http.sid = s->uniq_id;
|
||||||
es->ctx.http.state = state;
|
es->ctx.http.state = state;
|
||||||
es->ctx.http.b_flags = chn->flags;
|
es->ctx.http.b_flags = chn->flags;
|
||||||
@ -12782,14 +12799,10 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
|||||||
global.tune.bufsize - es->buf_out - es->buf_len,
|
global.tune.bufsize - es->buf_out - es->buf_len,
|
||||||
es->buf_len, es->buf_wrap, es->buf_err);
|
es->buf_len, es->buf_wrap, es->buf_err);
|
||||||
|
|
||||||
chunk_appendf(&trash,
|
if (es->show)
|
||||||
" stream #%d, stream flags 0x%08x, tx flags 0x%08x\n"
|
es->show(&trash, es);
|
||||||
" HTTP msg state %s(%d), msg flags 0x%08x\n"
|
|
||||||
" HTTP chunk len %lld bytes, HTTP body len %lld bytes, channel flags 0x%08x :\n \n",
|
chunk_appendf(&trash, " \n");
|
||||||
es->ctx.http.sid, es->ctx.http.s_flags, es->ctx.http.t_flags,
|
|
||||||
h1_msg_state_str(es->ctx.http.state), es->ctx.http.state,
|
|
||||||
es->ctx.http.m_flags, es->ctx.http.m_clen,
|
|
||||||
es->ctx.http.m_blen, es->ctx.http.b_flags);
|
|
||||||
|
|
||||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||||
/* Socket buffer full. Let's try again later from the same point */
|
/* Socket buffer full. Let's try again later from the same point */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user