From: Christopher Faulet Date: Tue, 20 Jun 2023 11:33:53 +0000 (+0200) Subject: MINOR: mux-h1: Add function to append the chunk size to the output buffer X-Git-Tag: v2.9-dev1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a07c85c5df17c0069e3ffb0a81baac941faaa4d0;p=thirdparty%2Fhaproxy.git MINOR: mux-h1: Add function to append the chunk size to the output buffer h1_append_chunk_size() function does the opposite of h1_prepend_chunk_size(). It emit the chunk size at the end of the output buffer. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 3986d32b0a..08b68605e0 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1420,6 +1420,24 @@ static void h1_prepend_chunk_size(struct buffer *buf, size_t chksz) b_add(buf, end - beg); } +/* Emit the chunksize followed by a CRLF after the data of the buffer + * . Returns 0 on error. + */ +static __maybe_unused int h1_append_chunk_size(struct buffer *buf, size_t chksz) +{ + char tmp[10]; + char *beg, *end; + + beg = end = tmp+10; + *--beg = '\n'; + *--beg = '\r'; + do { + *--beg = hextab[chksz & 0xF]; + } while (chksz >>= 4); + + return chunk_memcat(buf, beg, end - beg); +} + /* 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)