REORG: include: split common/http-hdr.h into haproxy/http-hdr{,-t}.h
There's only one struct and 2 inline functions. It could have been
merged into http.h but that would have added a massive dependency on
the hpack parts for nothing, so better keep it this way since hpack
is already freestanding and portable.
diff --git a/include/common/h1.h b/include/common/h1.h
index 7c341fe..879e041 100644
--- a/include/common/h1.h
+++ b/include/common/h1.h
@@ -26,7 +26,7 @@
#include <haproxy/dynbuf.h>
#include <haproxy/intops.h>
#include <haproxy/http.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
#include <import/ist.h>
diff --git a/include/common/h2.h b/include/common/h2.h
index 32f0206..42c3c5a 100644
--- a/include/common/h2.h
+++ b/include/common/h2.h
@@ -30,7 +30,7 @@
#define _COMMON_H2_H
#include <haproxy/api.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
#include <common/htx.h>
#include <import/ist.h>
diff --git a/include/common/hpack-tbl.h b/include/common/hpack-tbl.h
index 07e0a9f..b0ab4ff 100644
--- a/include/common/hpack-tbl.h
+++ b/include/common/hpack-tbl.h
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <haproxy/api.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
#include <import/ist.h>
#include <haproxy/pool.h>
diff --git a/include/common/htx.h b/include/common/htx.h
index 3c3ac0b..1b111a4 100644
--- a/include/common/htx.h
+++ b/include/common/htx.h
@@ -28,7 +28,7 @@
#include <import/ist.h>
#include <haproxy/chunk.h>
#include <haproxy/http-t.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
/*
* The internal representation of an HTTP message, called HTX, is a structure
diff --git a/include/common/http-hdr.h b/include/haproxy/http-hdr-t.h
similarity index 64%
copy from include/common/http-hdr.h
copy to include/haproxy/http-hdr-t.h
index 77997e3..3534f43 100644
--- a/include/common/http-hdr.h
+++ b/include/haproxy/http-hdr-t.h
@@ -1,7 +1,8 @@
/*
+ * include/haproxy/http-hdr-t.h
* HTTP header management (new model) - type definitions
*
- * Copyright (C) 2014-2017 Willy Tarreau <willy@haproxy.org>
+ * Copyright (C) 2014-2020 Willy Tarreau <willy@haproxy.org>
* Copyright (C) 2017 HAProxy Technologies
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -24,10 +25,9 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _COMMON_HTTP_HDR_H
-#define _COMMON_HTTP_HDR_H
+#ifndef _HAPROXY_HTTP_HDR_T_H
+#define _HAPROXY_HTTP_HDR_T_H
-#include <inttypes.h>
#include <import/ist.h>
/* a header field made of a name and a value. Such structure stores 4 longs so
@@ -38,30 +38,4 @@
struct ist v; /* value */
};
-/* sets an http_hdr <hdr> to name <n> and value <v>. Useful to avoid casts in
- * immediate assignments.
- */
-static inline void http_set_hdr(struct http_hdr *hdr, const struct ist n, const struct ist v)
-{
- hdr->n = n;
- 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 */
+#endif /* _HAPROXY_HTTP_HDR_T_H */
diff --git a/include/common/http-hdr.h b/include/haproxy/http-hdr.h
similarity index 82%
rename from include/common/http-hdr.h
rename to include/haproxy/http-hdr.h
index 77997e3..e9e253b 100644
--- a/include/common/http-hdr.h
+++ b/include/haproxy/http-hdr.h
@@ -1,5 +1,6 @@
/*
- * HTTP header management (new model) - type definitions
+ * include/haproxy/http-hdr.h
+ * HTTP header management (new model) - functions
*
* Copyright (C) 2014-2017 Willy Tarreau <willy@haproxy.org>
* Copyright (C) 2017 HAProxy Technologies
@@ -24,19 +25,11 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _COMMON_HTTP_HDR_H
-#define _COMMON_HTTP_HDR_H
+#ifndef _HAPROXY_HTTP_HDR_H
+#define _HAPROXY_HTTP_HDR_H
-#include <inttypes.h>
#include <import/ist.h>
-
-/* a header field made of a name and a value. Such structure stores 4 longs so
- * it takes 16 bytes on 32-bit systems and 32 bytes on 64-bit systems.
- */
-struct http_hdr {
- struct ist n; /* name */
- struct ist v; /* value */
-};
+#include <haproxy/http-hdr-t.h>
/* sets an http_hdr <hdr> to name <n> and value <v>. Useful to avoid casts in
* immediate assignments.
@@ -64,4 +57,4 @@
return dst;
}
-#endif /* _COMMON_HTTP_HDR_H */
+#endif /* _HAPROXY_HTTP_HDR_H */
diff --git a/src/h1.c b/src/h1.c
index f30e489..f143db9 100644
--- a/src/h1.c
+++ b/src/h1.c
@@ -13,7 +13,7 @@
#include <ctype.h>
#include <haproxy/api.h>
#include <common/h1.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr.h>
#include <proto/channel.h>
diff --git a/src/h2.c b/src/h2.c
index fa72e1c..c59c3f2 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -29,7 +29,7 @@
#include <haproxy/api.h>
#include <haproxy/http.h>
#include <common/h2.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
#include <import/ist.h>
#include <types/global.h>
diff --git a/src/hpack-enc.c b/src/hpack-enc.c
index bf7336b..21e28f6 100644
--- a/src/hpack-enc.c
+++ b/src/hpack-enc.c
@@ -31,7 +31,7 @@
#include <string.h>
#include <common/hpack-enc.h>
-#include <common/http-hdr.h>
+#include <haproxy/http-hdr-t.h>
#include <import/ist.h>
#include <types/global.h>