mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: http: remove the pointer to the error snapshot in http_capture_bad_message()
It's not needed anymore as we know the side thanks to the channel. This will allow the proxy generic code to better manage the error snapshots.
This commit is contained in:
parent
ef3ca73fc3
commit
fd9419d560
@ -99,7 +99,7 @@ int http_transform_header_str(struct stream* s, struct http_msg *msg, const char
|
|||||||
void inet_set_tos(int fd, const struct sockaddr_storage *from, int tos);
|
void inet_set_tos(int fd, const struct sockaddr_storage *from, int tos);
|
||||||
void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
|
void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
|
||||||
void http_return_srv_error(struct stream *s, struct stream_interface *si);
|
void http_return_srv_error(struct stream *s, struct stream_interface *si);
|
||||||
void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, struct stream *s,
|
void http_capture_bad_message(struct proxy *proxy, struct stream *s,
|
||||||
struct http_msg *msg,
|
struct http_msg *msg,
|
||||||
enum h1_state state, struct proxy *other_end);
|
enum h1_state state, struct proxy *other_end);
|
||||||
unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
|
unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
|
||||||
|
@ -1738,7 +1738,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
|
|
||||||
/* we cannot return any message on error */
|
/* we cannot return any message on error */
|
||||||
if (msg->err_pos >= 0) {
|
if (msg->err_pos >= 0) {
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
stream_inc_http_err_ctr(s);
|
stream_inc_http_err_ctr(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1771,7 +1771,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
|
|
||||||
/* read timeout : give up with an error message. */
|
/* read timeout : give up with an error message. */
|
||||||
if (msg->err_pos >= 0) {
|
if (msg->err_pos >= 0) {
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
stream_inc_http_err_ctr(s);
|
stream_inc_http_err_ctr(s);
|
||||||
}
|
}
|
||||||
txn->status = 408;
|
txn->status = 408;
|
||||||
@ -1803,7 +1803,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
goto failed_keep_alive;
|
goto failed_keep_alive;
|
||||||
|
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
txn->status = 400;
|
txn->status = 400;
|
||||||
msg->err_state = msg->msg_state;
|
msg->err_state = msg->msg_state;
|
||||||
msg->msg_state = HTTP_MSG_ERROR;
|
msg->msg_state = HTTP_MSG_ERROR;
|
||||||
@ -1896,7 +1896,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
* to block on that, so we have to capture it now.
|
* to block on that, so we have to capture it now.
|
||||||
*/
|
*/
|
||||||
if (unlikely(msg->err_pos >= 0))
|
if (unlikely(msg->err_pos >= 0))
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1: identify the method
|
* 1: identify the method
|
||||||
@ -2200,7 +2200,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
/* we detected a parsing error. We want to archive this request
|
/* we detected a parsing error. We want to archive this request
|
||||||
* in the dedicated proxy area for later troubleshooting.
|
* in the dedicated proxy area for later troubleshooting.
|
||||||
*/
|
*/
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn->req.err_state = txn->req.msg_state;
|
txn->req.err_state = txn->req.msg_state;
|
||||||
@ -3703,7 +3703,7 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
|||||||
/* we detected a parsing error. We want to archive this request
|
/* we detected a parsing error. We want to archive this request
|
||||||
* in the dedicated proxy area for later troubleshooting.
|
* in the dedicated proxy area for later troubleshooting.
|
||||||
*/
|
*/
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn->req.err_state = txn->req.msg_state;
|
txn->req.err_state = txn->req.msg_state;
|
||||||
@ -4054,7 +4054,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
/* we detected a parsing error. We want to archive this request
|
/* we detected a parsing error. We want to archive this request
|
||||||
* in the dedicated proxy area for later troubleshooting.
|
* in the dedicated proxy area for later troubleshooting.
|
||||||
*/
|
*/
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn->req.err_state = txn->req.msg_state;
|
txn->req.err_state = txn->req.msg_state;
|
||||||
@ -4997,7 +4997,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
|||||||
goto aborted_xfer;
|
goto aborted_xfer;
|
||||||
}
|
}
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, s->be);
|
http_capture_bad_message(sess->fe, s, msg, msg->err_state, s->be);
|
||||||
goto return_bad_req;
|
goto return_bad_req;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -5238,7 +5238,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
*/
|
*/
|
||||||
hdr_response_bad:
|
hdr_response_bad:
|
||||||
if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0)
|
if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
|
|
||||||
HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
|
HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
|
||||||
if (objt_server(s->target)) {
|
if (objt_server(s->target)) {
|
||||||
@ -5271,7 +5271,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
/* read error */
|
/* read error */
|
||||||
else if (rep->flags & CF_READ_ERROR) {
|
else if (rep->flags & CF_READ_ERROR) {
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
else if (txn->flags & TX_NOT_FIRST)
|
else if (txn->flags & TX_NOT_FIRST)
|
||||||
goto abort_keep_alive;
|
goto abort_keep_alive;
|
||||||
|
|
||||||
@ -5309,7 +5309,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
/* read timeout : return a 504 to the client. */
|
/* read timeout : return a 504 to the client. */
|
||||||
else if (rep->flags & CF_READ_TIMEOUT) {
|
else if (rep->flags & CF_READ_TIMEOUT) {
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
|
|
||||||
HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
|
HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
|
||||||
if (objt_server(s->target)) {
|
if (objt_server(s->target)) {
|
||||||
@ -5357,7 +5357,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
/* close from server, capture the response if the server has started to respond */
|
/* close from server, capture the response if the server has started to respond */
|
||||||
else if (rep->flags & CF_SHUTR) {
|
else if (rep->flags & CF_SHUTR) {
|
||||||
if (msg->msg_state >= HTTP_MSG_RPVER || msg->err_pos >= 0)
|
if (msg->msg_state >= HTTP_MSG_RPVER || msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
else if (txn->flags & TX_NOT_FIRST)
|
else if (txn->flags & TX_NOT_FIRST)
|
||||||
goto abort_keep_alive;
|
goto abort_keep_alive;
|
||||||
|
|
||||||
@ -5384,7 +5384,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
/* write error to client (we don't send any message then) */
|
/* write error to client (we don't send any message then) */
|
||||||
else if (rep->flags & CF_WRITE_ERROR) {
|
else if (rep->flags & CF_WRITE_ERROR) {
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
else if (txn->flags & TX_NOT_FIRST)
|
else if (txn->flags & TX_NOT_FIRST)
|
||||||
goto abort_keep_alive;
|
goto abort_keep_alive;
|
||||||
|
|
||||||
@ -5412,7 +5412,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (unlikely(msg->err_pos >= 0))
|
if (unlikely(msg->err_pos >= 0))
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
|
http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1: get the status code
|
* 1: get the status code
|
||||||
@ -6191,7 +6191,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
|||||||
goto aborted_xfer;
|
goto aborted_xfer;
|
||||||
}
|
}
|
||||||
if (msg->err_pos >= 0)
|
if (msg->err_pos >= 0)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, strm_fe(s));
|
http_capture_bad_message(s->be, s, msg, msg->err_state, strm_fe(s));
|
||||||
goto return_bad_res;
|
goto return_bad_res;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -6504,10 +6504,10 @@ http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg)
|
|||||||
chunk_parsing_error:
|
chunk_parsing_error:
|
||||||
if (msg->err_pos >= 0) {
|
if (msg->err_pos >= 0) {
|
||||||
if (chn->flags & CF_ISRESP)
|
if (chn->flags & CF_ISRESP)
|
||||||
http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg,
|
http_capture_bad_message(s->be, s, msg,
|
||||||
msg->msg_state, strm_fe(s));
|
msg->msg_state, strm_fe(s));
|
||||||
else
|
else
|
||||||
http_capture_bad_message(strm_fe(s), &strm_fe(s)->invalid_req, s,
|
http_capture_bad_message(strm_fe(s), s,
|
||||||
msg, msg->msg_state, s->be);
|
msg, msg->msg_state, s->be);
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
@ -8029,9 +8029,10 @@ void http_show_error_snapshot(struct buffer *out, const struct error_snapshot *e
|
|||||||
* 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
|
||||||
* this one is not set, it will then report msg->next, which is the last known
|
* this one is not set, it will then report msg->next, which is the last known
|
||||||
* parsing point. The function is able to deal with wrapping buffers. It always
|
* parsing point. The function is able to deal with wrapping buffers. It always
|
||||||
* displays buffers as a contiguous area starting at buf->p.
|
* displays buffers as a contiguous area starting at buf->p. The direction is
|
||||||
|
* determined thanks to the channel's flags.
|
||||||
*/
|
*/
|
||||||
void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, struct stream *s,
|
void http_capture_bad_message(struct proxy *proxy, struct stream *s,
|
||||||
struct http_msg *msg,
|
struct http_msg *msg,
|
||||||
enum h1_state state, struct proxy *other_end)
|
enum h1_state state, struct proxy *other_end)
|
||||||
{
|
{
|
||||||
@ -8052,7 +8053,7 @@ void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, st
|
|||||||
if (ofs < 0)
|
if (ofs < 0)
|
||||||
ofs = 0;
|
ofs = 0;
|
||||||
|
|
||||||
proxy_capture_error(proxy, es == &proxy->invalid_rep,
|
proxy_capture_error(proxy, !!(msg->chn->flags & CF_ISRESP),
|
||||||
other_end, s->target,
|
other_end, s->target,
|
||||||
strm_sess(s), &msg->chn->buf,
|
strm_sess(s), &msg->chn->buf,
|
||||||
ofs, co_data(msg->chn),
|
ofs, co_data(msg->chn),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user