]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: include: split common/http.h into haproxy/http{,-t}.h
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Jun 2020 17:11:26 +0000 (19:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 08:18:57 +0000 (10:18 +0200)
So the enums and structs were placed into http-t.h and the functions
into http.h. This revealed that several files were dependeng on http.h
but not including it, as it was silently inherited via other files.

30 files changed:
contrib/prometheus-exporter/service-prometheus.c
include/common/h1.h
include/common/hpack-enc.h
include/common/htx.h
include/haproxy/http-t.h [moved from include/common/http.h with 56% similarity]
include/haproxy/http.h [new file with mode: 0644]
include/types/http_ana.h
include/types/http_htx.h
include/types/proxy.h
include/types/sample.h
src/backend.c
src/checks.c
src/da.c
src/flt_http_comp.c
src/h1_htx.c
src/h2.c
src/hlua_fcn.c
src/http.c
src/http_acl.c
src/http_act.c
src/http_ana.c
src/http_conv.c
src/http_fetch.c
src/http_htx.c
src/http_rules.c
src/log.c
src/sample.c
src/session.c
src/stats.c
src/vars.c

index fe2520d62bd88464bafeb7da63e1d5a396a0601c..a07727e2e90c653238b232798fd6c20b106202fa 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 #include <haproxy/pool.h>
 #include <haproxy/list.h>
index 205a25ce2595a61a3358531950fa3d008e503cf5..7c341fe931373eeba0ebf95da98d7fafeb533b05 100644 (file)
@@ -25,7 +25,7 @@
 #include <haproxy/api.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/intops.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/http-hdr.h>
 #include <import/ist.h>
 
index 7d73b35648fc3991bf5a7f07e51211d42af682c3..ede8d284539e690106478fd2ae3b1e71dfbb652a 100644 (file)
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <haproxy/api.h>
 #include <haproxy/buf-t.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 #include <import/ist.h>
 
 int hpack_encode_header(struct buffer *out, const struct ist n,
index 664aaca9ed0cec311b91daa19baa23f1b94bad56..3c3ac0bf3b26ea6bd9e3148ce0eb7e0d1f9db1f4 100644 (file)
@@ -27,7 +27,7 @@
 #include <haproxy/buf.h>
 #include <import/ist.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 #include <common/http-hdr.h>
 
 /*
similarity index 56%
rename from include/common/http.h
rename to include/haproxy/http-t.h
index 0173b7acb479873ea4cc324a23bdbbdc286fed5a..c8bf9a30844cbd4c6b958d40051957aa7105d348 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * include/common/http.h
+ * include/haproxy/http-t.h
  *
  * Version-agnostic and implementation-agnostic HTTP protocol definitions.
  *
- * Copyright (C) 2000-2018 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _COMMON_HTTP_H
-#define _COMMON_HTTP_H
+#ifndef _HAPROXY_HTTP_T_H
+#define _HAPROXY_HTTP_T_H
 
-#include <haproxy/buf-t.h>
+#include <inttypes.h>
 #include <import/ist.h>
+#include <haproxy/buf-t.h>
 
 /*
  * some macros mainly used when parsing header fields.
@@ -122,84 +123,7 @@ struct http_method_desc {
        const struct ist text;
 };
 
-extern const int http_err_codes[HTTP_ERR_SIZE];
-extern const char *http_err_msgs[HTTP_ERR_SIZE];
-extern const struct ist http_known_methods[HTTP_METH_OTHER];
-extern const uint8_t http_char_classes[256];
-
-enum http_meth_t find_http_meth(const char *str, const int len);
-int http_get_status_idx(unsigned int status);
-const char *http_get_reason(unsigned int status);
-struct ist http_get_authority(const struct ist uri, int no_userinfo);
-struct ist http_get_path(const struct ist uri);
-int http_header_match2(const char *hdr, const char *end,
-                       const char *name, int len);
-char *http_find_hdr_value_end(char *s, const char *e);
-char *http_find_cookie_value_end(char *s, const char *e);
-char *http_extract_cookie_value(char *hdr, const char *hdr_end,
-                                char *cookie_name, size_t cookie_name_l,
-                                int list, char **value, size_t *value_l);
-int http_parse_qvalue(const char *qvalue, const char **end);
-const char *http_find_url_param_pos(const char **chunks,
-                                    const char* url_param_name,
-                                    size_t url_param_name_l, char delim);
-int http_find_next_url_param(const char **chunks,
-                             const char* url_param_name, size_t url_param_name_l,
-                             const char **vstart, const char **vend, char delim);
-
-int http_parse_header(const struct ist hdr, struct ist *name, struct ist *value);
-int http_parse_stline(const struct ist line, struct ist *p1, struct ist *p2, struct ist *p3);
-int http_parse_status_val(const struct ist value, struct ist *status, struct ist *reason);
-
-/*
- * Given a path string and its length, find the position of beginning of the
- * query string. Returns NULL if no query string is found in the path.
- *
- * Example: if path = "/foo/bar/fubar?yo=mama;ye=daddy", and n = 22:
- *
- * find_query_string(path, n, '?') points to "yo=mama;ye=daddy" string.
- */
-static inline char *http_find_param_list(char *path, size_t path_l, char delim)
-{
-       char *p;
-
-       p = memchr(path, delim, path_l);
-       return p ? p + 1 : NULL;
-}
-
-static inline int http_is_param_delimiter(char c, char delim)
-{
-       return c == '&' || c == ';' || c == delim;
-}
-
-/* Match language range with language tag. RFC2616 14.4:
- *
- *    A language-range matches a language-tag if it exactly equals
- *    the tag, or if it exactly equals a prefix of the tag such
- *    that the first tag character following the prefix is "-".
- *
- * Return 1 if the strings match, else return 0.
- */
-static inline int http_language_range_match(const char *range, int range_len,
-                                            const char *tag, int tag_len)
-{
-       const char *end = range + range_len;
-       const char *tend = tag + tag_len;
-
-       while (range < end) {
-               if (*range == '-' && tag == tend)
-                       return 1;
-               if (*range != *tag || tag == tend)
-                       return 0;
-               range++;
-               tag++;
-       }
-       /* Return true only if the last char of the tag is matched. */
-       return tag == tend;
-}
-
-
-#endif /* _COMMON_HTTP_H */
+#endif /* _HAPROXY_HTTP_T_H */
 
 /*
  * Local variables:
diff --git a/include/haproxy/http.h b/include/haproxy/http.h
new file mode 100644 (file)
index 0000000..64ac4bc
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * include/haproxy/http.h
+ *
+ * Functions for version-agnostic and implementation-agnostic HTTP protocol.
+ *
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _HAPROXY_HTTP_H
+#define _HAPROXY_HTTP_H
+
+#include <stddef.h>
+#include <string.h>
+#include <import/ist.h>
+#include <haproxy/http-t.h>
+
+extern const int http_err_codes[HTTP_ERR_SIZE];
+extern const char *http_err_msgs[HTTP_ERR_SIZE];
+extern const struct ist http_known_methods[HTTP_METH_OTHER];
+extern const uint8_t http_char_classes[256];
+
+enum http_meth_t find_http_meth(const char *str, const int len);
+int http_get_status_idx(unsigned int status);
+const char *http_get_reason(unsigned int status);
+struct ist http_get_authority(const struct ist uri, int no_userinfo);
+struct ist http_get_path(const struct ist uri);
+int http_header_match2(const char *hdr, const char *end,
+                       const char *name, int len);
+char *http_find_hdr_value_end(char *s, const char *e);
+char *http_find_cookie_value_end(char *s, const char *e);
+char *http_extract_cookie_value(char *hdr, const char *hdr_end,
+                                char *cookie_name, size_t cookie_name_l,
+                                int list, char **value, size_t *value_l);
+int http_parse_qvalue(const char *qvalue, const char **end);
+const char *http_find_url_param_pos(const char **chunks,
+                                    const char* url_param_name,
+                                    size_t url_param_name_l, char delim);
+int http_find_next_url_param(const char **chunks,
+                             const char* url_param_name, size_t url_param_name_l,
+                             const char **vstart, const char **vend, char delim);
+
+int http_parse_header(const struct ist hdr, struct ist *name, struct ist *value);
+int http_parse_stline(const struct ist line, struct ist *p1, struct ist *p2, struct ist *p3);
+int http_parse_status_val(const struct ist value, struct ist *status, struct ist *reason);
+
+/*
+ * Given a path string and its length, find the position of beginning of the
+ * query string. Returns NULL if no query string is found in the path.
+ *
+ * Example: if path = "/foo/bar/fubar?yo=mama;ye=daddy", and n = 22:
+ *
+ * find_query_string(path, n, '?') points to "yo=mama;ye=daddy" string.
+ */
+static inline char *http_find_param_list(char *path, size_t path_l, char delim)
+{
+       char *p;
+
+       p = memchr(path, delim, path_l);
+       return p ? p + 1 : NULL;
+}
+
+static inline int http_is_param_delimiter(char c, char delim)
+{
+       return c == '&' || c == ';' || c == delim;
+}
+
+/* Match language range with language tag. RFC2616 14.4:
+ *
+ *    A language-range matches a language-tag if it exactly equals
+ *    the tag, or if it exactly equals a prefix of the tag such
+ *    that the first tag character following the prefix is "-".
+ *
+ * Return 1 if the strings match, else return 0.
+ */
+static inline int http_language_range_match(const char *range, int range_len,
+                                            const char *tag, int tag_len)
+{
+       const char *end = range + range_len;
+       const char *tend = tag + tag_len;
+
+       while (range < end) {
+               if (*range == '-' && tag == tend)
+                       return 1;
+               if (*range != *tag || tag == tend)
+                       return 0;
+               range++;
+               tag++;
+       }
+       /* Return true only if the last char of the tag is matched. */
+       return tag == tend;
+}
+
+
+#endif /* _HAPROXY_HTTP_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 7bade13039caf1a58f68a8e6bb03b6d396cd6a09..4a1a9cdcefa049672f9ff590d85ded3dc9510666 100644 (file)
@@ -23,7 +23,7 @@
 #define _TYPES_PROTO_HTTP_H
 
 #include <haproxy/api-t.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 
 #include <types/channel.h>
 #include <types/http_htx.h>
index 4123e7e7cbe7eab42fc1a96b371677ea826e4bb2..2f6b10b52c129ada34eea69b4bce591bd94aae71 100644 (file)
@@ -26,7 +26,7 @@
 #include <import/ebistree.h>
 
 #include <haproxy/buf-t.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 #include <common/htx.h>
 #include <import/ist.h>
 
index 2e6a26cd845cce1b4906e11409b5b5898f2dad2f..2019de8050774e9a38394a40b84beaf69194ac8d 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <haproxy/api-t.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 #include <haproxy/list-t.h>
 #include <haproxy/thread.h>
 
index 618be08bf2edf573d2de51c1b2c547ee65ee363e..0bec0c4f90ef68819741dfb1baad7e332e66ac19 100644 (file)
@@ -27,7 +27,7 @@
 #include <netinet/in.h>
 
 #include <haproxy/buf-t.h>
-#include <common/http.h>
+#include <haproxy/http-t.h>
 #include <haproxy/list-t.h>
 
 struct arg;
index a002bbe0ae5d3174183d6f9cfea8d12cfa35569e..6d8596735059e8d96b14e7242f85782533c1e59e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/hash.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 #include <haproxy/ticks.h>
 #include <haproxy/time.h>
index 2374f65e7e62ee6523a5754a21db3c89a07ac6ad..b0d677621eb4bbfa4ea7aedd9d56b39cac622532 100644 (file)
@@ -39,7 +39,7 @@
 #include <common/standard.h>
 #include <haproxy/time.h>
 #include <haproxy/thread.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/h1.h>
 #include <common/htx.h>
 
index c783fb15229e3bbeb38ae4a34fd2947a6f2d1b9a..51f6e38234fbbd7e99c60ead1bfd7d590b9d03f6 100644 (file)
--- a/src/da.c
+++ b/src/da.c
@@ -3,7 +3,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <haproxy/errors.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <types/global.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
index 4b0e546ab6667400626eab19955d7bd836b322d7..5f0853a6d26c8f40e3dd20040f2c1b2f090e7a0b 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/dynbuf.h>
+#include <haproxy/http.h>
 #include <common/cfgparse.h>
 #include <common/htx.h>
 #include <haproxy/list.h>
index 6e582e389805b70e12cfc662b26672da2350c794..83ebfb1a157fea283bab36175e986a56a9e8a328 100644 (file)
@@ -13,7 +13,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <common/h1.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 
 #include <proto/h1_htx.h>
index c94ea8e0342d51555f264893dcd3a5d1f2bb452d..fa72e1c902bee272d4eeb6928d08f1654856f2a1 100644 (file)
--- a/src/h2.c
+++ b/src/h2.c
@@ -27,6 +27,7 @@
 
 #include <inttypes.h>
 #include <haproxy/api.h>
+#include <haproxy/http.h>
 #include <common/h2.h>
 #include <common/http-hdr.h>
 #include <import/ist.h>
index 53a2b4039a19bdec95ba2135caee79cee728c9cb..b759f11dec01de0146315c2669cabdc03900ce3d 100644 (file)
@@ -18,6 +18,7 @@
 #include <lua.h>
 #include <lualib.h>
 
+#include <haproxy/http.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/regex.h>
 #include <haproxy/time.h>
index 0bd8f87ffb21ed2fbe5a942a64b2190304eb3a91..ae315a82879675f55ae62b347439c910de6b6a1e 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <ctype.h>
 #include <haproxy/api.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/standard.h>
 
 /* It is about twice as fast on recent architectures to lookup a byte in a
index 368a4b113c57ce9120702bc0720400aefcda4ade..780962af2607c106213616dd6913fac1f93fafa5 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/pool.h>
 #include <common/standard.h>
 #include <haproxy/version.h>
index 4193b91c102a8531423fea7626dfdad84ce823df..a5ce9d780f896fec5c20f34d67dac821cb314747 100644 (file)
@@ -19,7 +19,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/pool.h>
 #include <haproxy/regex.h>
 #include <common/standard.h>
index 9f6508277778def153ec704bddbfadaa7f20aeae..d89bcf54b36895c4731e3d79428e27ac611bac3c 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/base64.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/regex.h>
index 8937fa0b8cb7f6876e6223b0ee45f9fd3fdf8b8c..72cb4af68ff88331c70ac8c6806f175e6199cccc 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/pool.h>
 #include <common/standard.h>
 #include <haproxy/version.h>
index 8fe22b8cc509006a921d8fc61f2abe56891319d3..2d996428214771773f7fb5ca9042b62bf6e14a47 100644 (file)
@@ -20,7 +20,7 @@
 #include <haproxy/base64.h>
 #include <haproxy/chunk.h>
 #include <common/h1.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 #include <haproxy/pool.h>
 #include <common/standard.h>
index af8758c992d6f7b80148e75d6ed7e870d3cdccfc..ede8a0ea214c379de63b1104164a3e73c2439042 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <common/cfgparse.h>
 #include <common/h1.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 
 #include <proto/arg.h>
index 96508e9a8446134354a9dae0e0e2d1f6fdf2e8a3..94aff63c79e40412dd0648f8b745fa6cf0425133 100644 (file)
@@ -19,7 +19,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <haproxy/chunk.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/pool.h>
 #include <common/standard.h>
 #include <haproxy/version.h>
index d4f49226c87da3568ec1e42e4af5c05d69f436a2..5778994b77a82f26019b7251a4522c2fb0b896ba 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -25,6 +25,7 @@
 #include <sys/uio.h>
 
 #include <haproxy/api.h>
+#include <haproxy/http.h>
 #include <common/standard.h>
 #include <haproxy/time.h>
 #include <haproxy/version.h>
index 14615a1ba1ec33563b87bccac7356a29f9cf98a9..380dd6fb06c04040e14d4dd2fc418766fb112de2 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <haproxy/chunk.h>
 #include <haproxy/hash.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/regex.h>
 #include <common/standard.h>
index d31806a2ba28ac8459ed0271f26ae9b6ff82f68d..619ff069a372efe40bcf88edac5754a0b8a9af5c 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include <haproxy/api.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/pool.h>
 
 #include <types/global.h>
index b5f5e9c89b0ddb2f6756d62e96961d0b17eeb3ab..4820d3b8bb64db5adbb1c33e3229691bc2af6c76 100644 (file)
@@ -27,7 +27,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <haproxy/debug.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <common/htx.h>
 #include <haproxy/pool.h>
 #include <haproxy/list.h>
index 227c94b9f4536cfeba97c81342a37b3501cdb3e8..edcf1af1c0b666fcf858455e7c5ea1bcc76e466c 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
-#include <common/http.h>
+#include <haproxy/http.h>
 #include <haproxy/list.h>
 
 #include <types/vars.h>