mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-15 21:59:41 -04:00
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.
This commit is contained in:
parent
c4e53f4ad7
commit
e2c418e94b
1 changed files with 17 additions and 0 deletions
|
|
@ -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 <n> in list <hdr> 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 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue