From 3fe693b4d6c3e912688c1996a977cd4d56ed7334 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 12 Dec 2010 12:50:05 +0100 Subject: [PATCH] [BUG] http chunking: don't report a parsing error on connection errors When haproxy parses chunk-encoded data that are scheduled to be sent, it is possible that the other end is closed (mainly due to a client abort returning as an error). The message state thus changes to HTTP_MSG_ERROR and the error is reported as a chunk parsing error ("PD--") while it is not. Detect this case before setting the flags and set the appropriate flag in this case. --- src/proto_http.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index 893f8da29..670ecd118 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -4407,8 +4407,18 @@ int http_request_forward_body(struct session *s, struct buffer *req, int an_bit) /* some state changes occurred, maybe the analyser * was disabled too. */ - if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) + if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { + if (req->flags & BF_SHUTW) { + /* request errors are most likely due to + * the server aborting the transfer. + */ + if (!(s->flags & SN_ERR_MASK)) + s->flags |= SN_ERR_SRVCL; + if (!(s->flags & SN_FINST_MASK)) + s->flags |= SN_FINST_D; + } goto return_bad_req; + } return 1; } @@ -5385,8 +5395,18 @@ int http_response_forward_body(struct session *s, struct buffer *res, int an_bit /* some state changes occurred, maybe the analyser * was disabled too. */ - if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) + if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { + if (res->flags & BF_SHUTW) { + /* response errors are most likely due to + * the client aborting the transfer. + */ + if (!(s->flags & SN_ERR_MASK)) + s->flags |= SN_ERR_CLICL; + if (!(s->flags & SN_FINST_MASK)) + s->flags |= SN_FINST_D; + } goto return_bad_res; + } return 1; } return 0;