From: Willy Tarreau Date: Sun, 27 Dec 2009 14:45:38 +0000 (+0100) Subject: [MINOR] buffers: add buffer_ignore() to skip some bytes X-Git-Tag: v1.4-dev5~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d21e01c63fec778f85f8321bbb373ab90ec96fb3;p=thirdparty%2Fhaproxy.git [MINOR] buffers: add buffer_ignore() to skip some bytes This simple function will be used to skip blanks at the beginning of a request or response. --- diff --git a/include/proto/buffers.h b/include/proto/buffers.h index c19a284fc9..d5dd781bcb 100644 --- a/include/proto/buffers.h +++ b/include/proto/buffers.h @@ -173,6 +173,21 @@ static inline void buffer_cut_tail(struct buffer *buf) buf->flags |= BF_FULL; } +/* Cut the next unsent bytes of the buffer. The caller must ensure that + * is smaller than the actual buffer's length. This is mainly used to remove + * empty lines at the beginning of a request or a response. + */ +static inline void buffer_ignore(struct buffer *buf, int n) +{ + buf->l -= n; + buf->w += n; + if (buf->w >= buf->data + buf->size) + buf->w -= buf->size; + buf->flags &= ~BF_FULL; + if (buf->l >= buffer_max_len(buf)) + buf->flags |= BF_FULL; +} + /* marks the buffer as "shutdown" ASAP for reads */ static inline void buffer_shutr_now(struct buffer *buf) {