[BUG] http: take care of errors, timeouts and aborts during the data phase

In server-close mode particularly, the response buffer is marked for
no-auto-close after a response passed through. This prevented a POST
request from being aborted on errors, timeouts or anything if the
response was received before the request was complete.
diff --git a/src/proto_http.c b/src/proto_http.c
index 1648083..2cab198 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3256,7 +3256,10 @@
 	struct http_txn *txn = &s->txn;
 	struct http_msg *msg = &s->txn.req;
 
-	if (req->flags & (BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) {
+	if ((req->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
+	    ((req->flags & BF_SHUTW) && (req->to_forward || req->send_max))) {
+		/* Output closed while we were sending data. We must abort. */
+		buffer_ignore(req, req->l - req->send_max);
 		req->analysers &= ~an_bit;
 		return 1;
 	}
@@ -4368,7 +4371,11 @@
 	struct http_txn *txn = &s->txn;
 	struct http_msg *msg = &s->txn.rsp;
 
-	if (res->flags & (BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) {
+	if ((res->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
+	    !s->req->analysers) {
+		/* in case of error or if the other analyser went away, we can't analyse HTTP anymore */
+		buffer_ignore(res, res->l - res->send_max);
+		buffer_auto_close(res);
 		res->analysers &= ~an_bit;
 		return 1;
 	}
@@ -4515,6 +4522,8 @@
 		}
 	}
 
+	buffer_ignore(res, res->l - res->send_max);
+	buffer_auto_close(res);
 	res->analysers &= ~an_bit;
 	return 1;