/src/haproxy/include/haproxy/http-hdr.h
Line | Count | Source |
1 | | /* |
2 | | * include/haproxy/http-hdr.h |
3 | | * HTTP header management (new model) - functions |
4 | | * |
5 | | * Copyright (C) 2014-2017 Willy Tarreau <willy@haproxy.org> |
6 | | * Copyright (C) 2017 HAProxy Technologies |
7 | | * |
8 | | * Permission is hereby granted, free of charge, to any person obtaining |
9 | | * a copy of this software and associated documentation files (the |
10 | | * "Software"), to deal in the Software without restriction, including |
11 | | * without limitation the rights to use, copy, modify, merge, publish, |
12 | | * distribute, sublicense, and/or sell copies of the Software, and to |
13 | | * permit persons to whom the Software is furnished to do so, subject to |
14 | | * the following conditions: |
15 | | * |
16 | | * The above copyright notice and this permission notice shall be |
17 | | * included in all copies or substantial portions of the Software. |
18 | | * |
19 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
20 | | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
21 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
22 | | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
23 | | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
24 | | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
25 | | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
26 | | * OTHER DEALINGS IN THE SOFTWARE. |
27 | | */ |
28 | | #ifndef _HAPROXY_HTTP_HDR_H |
29 | | #define _HAPROXY_HTTP_HDR_H |
30 | | |
31 | | #include <import/ist.h> |
32 | | #include <haproxy/http-hdr-t.h> |
33 | | |
34 | | /* sets an http_hdr <hdr> to name <n> and value <v>. Useful to avoid casts in |
35 | | * immediate assignments. |
36 | | */ |
37 | | static inline void http_set_hdr(struct http_hdr *hdr, const struct ist n, const struct ist v) |
38 | 31.8k | { |
39 | 31.8k | hdr->n = n; |
40 | 31.8k | hdr->v = v; |
41 | 31.8k | } Unexecuted instantiation: fuzz_h1_htx.c:http_set_hdr Unexecuted instantiation: h1_htx.c:http_set_hdr Unexecuted instantiation: http_htx.c:http_set_hdr Line | Count | Source | 38 | 31.8k | { | 39 | 31.8k | hdr->n = n; | 40 | 31.8k | hdr->v = v; | 41 | 31.8k | } |
|
42 | | |
43 | | /* removes all occurrences of header name <n> in list <hdr> and returns the new count. The |
44 | | * list must be terminated by the empty header. |
45 | | */ |
46 | | static inline int http_del_hdr(struct http_hdr *hdr, const struct ist n) |
47 | 379 | { |
48 | 379 | int src = 0, dst = 0; |
49 | | |
50 | 6.28k | do { |
51 | 6.28k | if (!isteqi(hdr[src].n, n)) { |
52 | 5.27k | if (src != dst) |
53 | 2.81k | hdr[dst] = hdr[src]; |
54 | 5.27k | dst++; |
55 | 5.27k | } |
56 | 6.28k | } while (hdr[src++].n.len); |
57 | | |
58 | 379 | return dst; |
59 | 379 | } Unexecuted instantiation: fuzz_h1_htx.c:http_del_hdr Line | Count | Source | 47 | 271 | { | 48 | 271 | int src = 0, dst = 0; | 49 | | | 50 | 3.97k | do { | 51 | 3.97k | if (!isteqi(hdr[src].n, n)) { | 52 | 3.06k | if (src != dst) | 53 | 1.60k | hdr[dst] = hdr[src]; | 54 | 3.06k | dst++; | 55 | 3.06k | } | 56 | 3.97k | } while (hdr[src++].n.len); | 57 | | | 58 | 271 | return dst; | 59 | 271 | } |
Unexecuted instantiation: http_htx.c:http_del_hdr Line | Count | Source | 47 | 108 | { | 48 | 108 | int src = 0, dst = 0; | 49 | | | 50 | 2.31k | do { | 51 | 2.31k | if (!isteqi(hdr[src].n, n)) { | 52 | 2.20k | if (src != dst) | 53 | 1.20k | hdr[dst] = hdr[src]; | 54 | 2.20k | dst++; | 55 | 2.20k | } | 56 | 2.31k | } while (hdr[src++].n.len); | 57 | | | 58 | 108 | return dst; | 59 | 108 | } |
|
60 | | #endif /* _HAPROXY_HTTP_HDR_H */ |