From: Willy Tarreau Date: Fri, 14 Sep 2018 15:32:05 +0000 (+0200) Subject: MINOR: http: add http_hdr_del() to remove a header from a list X-Git-Tag: v1.9-dev3~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e2c418e94bb6264e63efa3b44c023d19d646b767;p=thirdparty%2Fhaproxy.git MINOR: http: add http_hdr_del() to remove a header from a list This one removes all occurrences of the specified header field name from a complete list and returns the new count. --- diff --git a/include/common/http-hdr.h b/include/common/http-hdr.h index a0bb341bbb..8cc7ee7830 100644 --- a/include/common/http-hdr.h +++ b/include/common/http-hdr.h @@ -47,4 +47,21 @@ static inline void http_set_hdr(struct http_hdr *hdr, const struct ist n, const hdr->v = v; } +/* removes all occurrences of header name in list and returns the new count. The + * list must be terminated by the empty header. + */ +static inline int http_del_hdr(struct http_hdr *hdr, const struct ist n) +{ + int src = 0, dst = 0; + + do { + if (!isteqi(hdr[src].n, n)) { + if (src != dst) + hdr[dst] = hdr[src]; + dst++; + } + } while (hdr[src++].n.len); + + return dst; +} #endif /* _COMMON_HTTP_HDR_H */