From: Christopher Faulet Date: Tue, 20 Jun 2023 11:33:59 +0000 (+0200) Subject: MINOR: mux-h1: Add function to prepend the chunk crlf to the output buffer X-Git-Tag: v2.9-dev1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05fe76b540210a27c9e2fc96ced740ec48fa19b8;p=thirdparty%2Fhaproxy.git MINOR: mux-h1: Add function to prepend the chunk crlf to the output buffer h1_prepend_chunk_crlf() function does the opposite of h1_append_chunk_crlf(). It emit the chunk size in front of the output buffer. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 08b68605e0..7722575541 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1438,6 +1438,22 @@ static __maybe_unused int h1_append_chunk_size(struct buffer *buf, size_t chksz) return chunk_memcat(buf, beg, end - beg); } +/* Emit a CRLF in front of data of the buffer . It goes backwards and + * starts with the byte before the buffer's head. The caller is responsible for + * ensuring there is enough room left before the buffer's head for the string. + */ +static __maybe_unused void h1_prepend_chunk_crlf(struct buffer *buf) +{ + char *head; + + head = b_head(buf); + *--head = '\n'; + *--head = '\r'; + buf->head -= 2; + b_add(buf, 2); +} + + /* Emit a CRLF after the data of the buffer . The caller is responsible for * ensuring there is enough room left in the buffer for the string. */ static void h1_append_chunk_crlf(struct buffer *buf)