From: Willy Tarreau Date: Sun, 25 Mar 2007 21:47:23 +0000 (+0200) Subject: [MEDIUM] do not add Connection: close in HTTP/1.0 mode X-Git-Tag: v1.3.8~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2807efdb02a85d41b7ad524406629b4fa49f9cca;p=thirdparty%2Fhaproxy.git [MEDIUM] do not add Connection: close in HTTP/1.0 mode If we already are in HTTP/1.0 and if no connection: has been seen, it is not necessary to add Connection: close. --- diff --git a/src/proto_http.c b/src/proto_http.c index d0eeb564de..6728eb3493 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1695,10 +1695,13 @@ int process_cli(struct session *t) /* * 10: add "Connection: close" if needed and not yet set. + * Note that we do not need to add it in case of HTTP/1.0. */ - if (((t->fe->options | t->be->beprm->options) & PR_O_HTTP_CLOSE) && - !(t->flags & SN_CONN_CLOSED)) { - if (unlikely(http_header_add_tail2(req, &txn->req, &txn->hdr_idx, + if (!(t->flags & SN_CONN_CLOSED) && + ((t->fe->options | t->be->beprm->options) & PR_O_HTTP_CLOSE)) { + if ((unlikely(msg->sl.rq.v_l != 8) || + unlikely(req->data[msg->som + msg->sl.rq.v + 7] != '0')) && + unlikely(http_header_add_tail2(req, &txn->req, &txn->hdr_idx, "Connection: close", 17)) < 0) goto return_bad_req; t->flags |= SN_CONN_CLOSED; @@ -2737,10 +2740,13 @@ int process_srv(struct session *t) /* * 8: add "Connection: close" if needed and not yet set. + * Note that we do not need to add it in case of HTTP/1.0. */ - if (((t->fe->options | t->be->beprm->options) & PR_O_HTTP_CLOSE) && - !(t->flags & SN_CONN_CLOSED)) { - if (unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx, + if (!(t->flags & SN_CONN_CLOSED) && + ((t->fe->options | t->be->beprm->options) & PR_O_HTTP_CLOSE)) { + if ((unlikely(msg->sl.st.v_l != 8) || + unlikely(req->data[msg->som + 7] != '0')) && + unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx, "Connection: close", 17)) < 0) goto return_bad_resp; t->flags |= SN_CONN_CLOSED;