]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: maintain consistence between channel_forward and HTTP forward
authorWilly Tarreau <w@1wt.eu>
Thu, 9 Jul 2015 16:38:57 +0000 (18:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2015 09:37:29 +0000 (11:37 +0200)
When the HTTP forwarder is used, it resets msg->sov so that we know that
the parsing pointer has advanced by exactly (msg->eoh + msg->eol - msg->sov)
bytes which may have to be rewound in case we want to perform an HTTP fetch
after forwarding has started (eg: upon connect).

But when the backend is in TCP mode, there may be no HTTP forwarding
analyser installed, still we may want to perform these HTTP fetches in
case we have already ensured at the TCP layer that we have a properly
parsed HTTP transaction.

In order to solve this, we reset msg->sov before doing a channel_forward()
so that we can still compute http_rewind() on the pending data. That ensures
the buffer is always rewindable even in mixed TCP+HTTP mode.

src/stream.c

index 10038268dd6c4fa8b615a8c8262a78b733e3c12a..0cd5bb63e00660776387998f6c518260e11f979f 100644 (file)
@@ -1987,6 +1987,14 @@ struct task *process_stream(struct task *t)
                 */
                if (!(req->flags & (CF_SHUTR|CF_SHUTW_NOW)))
                        channel_forward(req, CHN_INFINITE_FORWARD);
+
+               /* Just in order to support fetching HTTP contents after start
+                * of forwarding when the HTTP forwarding analyser is not used,
+                * we simply reset msg->sov so that HTTP rewinding points to the
+                * headers.
+                */
+               if (s->txn)
+                       s->txn->req.sov = s->txn->req.eoh + s->txn->req.eol - req->buf->o;
        }
 
        /* check if it is wise to enable kernel splicing to forward request data */
@@ -2150,6 +2158,14 @@ struct task *process_stream(struct task *t)
                if (!(res->flags & (CF_SHUTR|CF_SHUTW_NOW)))
                        channel_forward(res, CHN_INFINITE_FORWARD);
 
+               /* Just in order to support fetching HTTP contents after start
+                * of forwarding when the HTTP forwarding analyser is not used,
+                * we simply reset msg->sov so that HTTP rewinding points to the
+                * headers.
+                */
+               if (s->txn)
+                       s->txn->rsp.sov = s->txn->rsp.eoh + s->txn->rsp.eol - res->buf->o;
+
                /* if we have no analyser anymore in any direction and have a
                 * tunnel timeout set, use it now. Note that we must respect
                 * the half-closed timeouts as well.