[MAJOR] buffers: automatically compute the maximum buffer length
We used to apply a limit to each buffer's size in order to leave
some room to rewrite headers, then we used to remove this limit
once the session switched to a data state.
Proceeding that way becomes a problem with keepalive because we
have to know when to stop reading too much data into the buffer
so that we can leave some room again to process next requests.
The principle we adopt here consists in only relying on to_forward+send_max.
Indeed, both of those data define how many bytes will leave the buffer.
So as long as their sum is larger than maxrewrite, we can safely
fill the buffers. If they are smaller, then we refrain from filling
the buffer. This means that we won't risk to fill buffers when
reading last data chunk followed by a POST request and its contents.
The only impact identified so far is that we must ensure that the
BF_FULL flag is correctly dropped when starting to forward. Right
now this is OK because nobody inflates to_forward without using
buffer_forward().
diff --git a/src/client.c b/src/client.c
index 79bb9d9..492cae7 100644
--- a/src/client.c
+++ b/src/client.c
@@ -400,10 +400,8 @@
s->req->flags |= BF_READ_ATTACHED; /* the producer is already connected */
- if (p->mode == PR_MODE_HTTP) { /* reserve some space for header rewriting */
- s->req->max_len -= global.tune.maxrewrite;
+ if (p->mode == PR_MODE_HTTP)
s->req->flags |= BF_READ_DONTWAIT; /* one read is usually enough */
- }
/* activate default analysers enabled for this listener */
s->req->analysers = l->analysers;