package: haproxy
[packages.git] / net / haproxy / patches / 0019-BUG-MINOR-http-don-t-abort-client-connection-o-1.4.22.diff
1 From dc624fd282caae163b11c197b36851e0ecf373eb Mon Sep 17 00:00:00 2001
2 From: Willy Tarreau <w@1wt.eu>
3 Date: Thu, 20 Dec 2012 12:10:09 +0100
4 Subject: BUG/MINOR: http: don't abort client connection on premature responses
5
6 When a server responds prematurely to a POST request, haproxy used to
7 cause the transfer to be aborted before the end. This is problematic
8 because this causes the client to receive a TCP reset when it tries to
9 push more data, generally preventing it from receiving the response
10 which contain the reason for the premature reponse (eg: "entity too
11 large" or an authentication request).
12
13 From now on we take care of allowing the upload traffic to flow to the
14 server even when the response has been received, since the server is
15 supposed to drain it. That way the client receives the server response.
16
17 This bug has been present since 1.4 and the fix should probably be
18 backported there.
19 (cherry picked from commit 40f151aa79bcdf8b517c4e5666edbc7a47ea7fdc)
20
21 Note: 1.4 does not have SI_FL_NOHALF but this is not important.
22 ---
23  src/proto_http.c |    5 +++--
24  1 files changed, 3 insertions(+), 2 deletions(-)
25
26 diff --git a/src/proto_http.c b/src/proto_http.c
27 index 7a8872b..e4cec6d 100644
28 --- a/src/proto_http.c
29 +++ b/src/proto_http.c
30 @@ -4443,9 +4443,10 @@ int http_resync_states(struct session *s)
31                 buffer_auto_close(s->rep);
32                 buffer_auto_read(s->rep);
33         }
34 -       else if (txn->rsp.msg_state == HTTP_MSG_CLOSED ||
35 +       else if ((txn->req.msg_state >= HTTP_MSG_DONE &&
36 +                 (txn->rsp.msg_state == HTTP_MSG_CLOSED || (s->rep->flags & BF_SHUTW))) ||
37                  txn->rsp.msg_state == HTTP_MSG_ERROR ||
38 -                (s->rep->flags & BF_SHUTW)) {
39 +                txn->req.msg_state == HTTP_MSG_ERROR) {
40                 s->rep->analysers = 0;
41                 buffer_auto_close(s->rep);
42                 buffer_auto_read(s->rep);
43 -- 
44 1.7.1
45