REORG: http: move the HTTP semantics definitions to http.h/http.c
It's a bit painful to have to deal with HTTP semantics for each protocol
version (H1 and H2), and working on the version-agnostic code further
emphasizes the problem.
This patch creates http.h and http.c which are agnostic to the version
in use, and which borrow a few parts from proto_http and from h1. For
example the once thought h1-specific h1_char_classes array is in fact
dictated by RFC7231 and is used to parse HTTP headers. A few changes
were made to a few files which were including proto_http.h while they
only needed http.h.
Certain string definitions pre-dated the introduction of indirect
strings (ist) so some were used to simplify the definition of the known
HTTP methods. The current lookup code saves 2 kB of a heavily used table
and is faster than the previous table based lookup (typ. 14 ns vs 16
before).
diff --git a/src/checks.c b/src/checks.c
index 28ee4c4..b64d32e 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -49,7 +49,6 @@
#include <proto/mux_pt.h>
#include <proto/queue.h>
#include <proto/port_range.h>
-#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/protocol.h>
#include <proto/proxy.h>
diff --git a/src/compression.c b/src/compression.c
index 3e98402..e7ce90a 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -37,7 +37,6 @@
#include <proto/acl.h>
#include <proto/compression.h>
#include <proto/freq_ctr.h>
-#include <proto/proto_http.h>
#include <proto/stream.h>
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index bf8f81a..81e1b42 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -17,7 +17,7 @@
#include <types/compression.h>
#include <types/filters.h>
-#include <types/proto_http.h>
+#include <types/h1.h>
#include <types/proxy.h>
#include <types/sample.h>
diff --git a/src/h1.c b/src/h1.c
index 63ff993..325f5b6 100644
--- a/src/h1.c
+++ b/src/h1.c
@@ -18,147 +18,6 @@
#include <proto/h1.h>
#include <proto/hdr_idx.h>
-/* It is about twice as fast on recent architectures to lookup a byte in a
- * table than to perform a boolean AND or OR between two tests. Refer to
- * RFC2616/RFC5234/RFC7230 for those chars. A token is any ASCII char that is
- * neither a separator nor a CTL char. An http ver_token is any ASCII which can
- * be found in an HTTP version, which includes 'H', 'T', 'P', '/', '.' and any
- * digit. Note: please do not overwrite values in assignment since gcc-2.95
- * will not handle them correctly. It's worth noting that chars 128..255 are
- * nothing, not even control chars.
- */
-const unsigned char h1_char_classes[256] = {
- [ 0] = H1_FLG_CTL,
- [ 1] = H1_FLG_CTL,
- [ 2] = H1_FLG_CTL,
- [ 3] = H1_FLG_CTL,
- [ 4] = H1_FLG_CTL,
- [ 5] = H1_FLG_CTL,
- [ 6] = H1_FLG_CTL,
- [ 7] = H1_FLG_CTL,
- [ 8] = H1_FLG_CTL,
- [ 9] = H1_FLG_SPHT | H1_FLG_LWS | H1_FLG_SEP | H1_FLG_CTL,
- [ 10] = H1_FLG_CRLF | H1_FLG_LWS | H1_FLG_CTL,
- [ 11] = H1_FLG_CTL,
- [ 12] = H1_FLG_CTL,
- [ 13] = H1_FLG_CRLF | H1_FLG_LWS | H1_FLG_CTL,
- [ 14] = H1_FLG_CTL,
- [ 15] = H1_FLG_CTL,
- [ 16] = H1_FLG_CTL,
- [ 17] = H1_FLG_CTL,
- [ 18] = H1_FLG_CTL,
- [ 19] = H1_FLG_CTL,
- [ 20] = H1_FLG_CTL,
- [ 21] = H1_FLG_CTL,
- [ 22] = H1_FLG_CTL,
- [ 23] = H1_FLG_CTL,
- [ 24] = H1_FLG_CTL,
- [ 25] = H1_FLG_CTL,
- [ 26] = H1_FLG_CTL,
- [ 27] = H1_FLG_CTL,
- [ 28] = H1_FLG_CTL,
- [ 29] = H1_FLG_CTL,
- [ 30] = H1_FLG_CTL,
- [ 31] = H1_FLG_CTL,
- [' '] = H1_FLG_SPHT | H1_FLG_LWS | H1_FLG_SEP,
- ['!'] = H1_FLG_TOK,
- ['"'] = H1_FLG_SEP,
- ['#'] = H1_FLG_TOK,
- ['$'] = H1_FLG_TOK,
- ['%'] = H1_FLG_TOK,
- ['&'] = H1_FLG_TOK,
- [ 39] = H1_FLG_TOK,
- ['('] = H1_FLG_SEP,
- [')'] = H1_FLG_SEP,
- ['*'] = H1_FLG_TOK,
- ['+'] = H1_FLG_TOK,
- [','] = H1_FLG_SEP,
- ['-'] = H1_FLG_TOK,
- ['.'] = H1_FLG_TOK | H1_FLG_VER,
- ['/'] = H1_FLG_SEP | H1_FLG_VER,
- ['0'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['1'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['2'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['3'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['4'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['5'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['6'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['7'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['8'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- ['9'] = H1_FLG_TOK | H1_FLG_VER | H1_FLG_DIG,
- [':'] = H1_FLG_SEP,
- [';'] = H1_FLG_SEP,
- ['<'] = H1_FLG_SEP,
- ['='] = H1_FLG_SEP,
- ['>'] = H1_FLG_SEP,
- ['?'] = H1_FLG_SEP,
- ['@'] = H1_FLG_SEP,
- ['A'] = H1_FLG_TOK,
- ['B'] = H1_FLG_TOK,
- ['C'] = H1_FLG_TOK,
- ['D'] = H1_FLG_TOK,
- ['E'] = H1_FLG_TOK,
- ['F'] = H1_FLG_TOK,
- ['G'] = H1_FLG_TOK,
- ['H'] = H1_FLG_TOK | H1_FLG_VER,
- ['I'] = H1_FLG_TOK,
- ['J'] = H1_FLG_TOK,
- ['K'] = H1_FLG_TOK,
- ['L'] = H1_FLG_TOK,
- ['M'] = H1_FLG_TOK,
- ['N'] = H1_FLG_TOK,
- ['O'] = H1_FLG_TOK,
- ['P'] = H1_FLG_TOK | H1_FLG_VER,
- ['Q'] = H1_FLG_TOK,
- ['R'] = H1_FLG_TOK | H1_FLG_VER,
- ['S'] = H1_FLG_TOK | H1_FLG_VER,
- ['T'] = H1_FLG_TOK | H1_FLG_VER,
- ['U'] = H1_FLG_TOK,
- ['V'] = H1_FLG_TOK,
- ['W'] = H1_FLG_TOK,
- ['X'] = H1_FLG_TOK,
- ['Y'] = H1_FLG_TOK,
- ['Z'] = H1_FLG_TOK,
- ['['] = H1_FLG_SEP,
- [ 92] = H1_FLG_SEP,
- [']'] = H1_FLG_SEP,
- ['^'] = H1_FLG_TOK,
- ['_'] = H1_FLG_TOK,
- ['`'] = H1_FLG_TOK,
- ['a'] = H1_FLG_TOK,
- ['b'] = H1_FLG_TOK,
- ['c'] = H1_FLG_TOK,
- ['d'] = H1_FLG_TOK,
- ['e'] = H1_FLG_TOK,
- ['f'] = H1_FLG_TOK,
- ['g'] = H1_FLG_TOK,
- ['h'] = H1_FLG_TOK,
- ['i'] = H1_FLG_TOK,
- ['j'] = H1_FLG_TOK,
- ['k'] = H1_FLG_TOK,
- ['l'] = H1_FLG_TOK,
- ['m'] = H1_FLG_TOK,
- ['n'] = H1_FLG_TOK,
- ['o'] = H1_FLG_TOK,
- ['p'] = H1_FLG_TOK,
- ['q'] = H1_FLG_TOK,
- ['r'] = H1_FLG_TOK,
- ['s'] = H1_FLG_TOK,
- ['t'] = H1_FLG_TOK,
- ['u'] = H1_FLG_TOK,
- ['v'] = H1_FLG_TOK,
- ['w'] = H1_FLG_TOK,
- ['x'] = H1_FLG_TOK,
- ['y'] = H1_FLG_TOK,
- ['z'] = H1_FLG_TOK,
- ['{'] = H1_FLG_SEP,
- ['|'] = H1_FLG_TOK,
- ['}'] = H1_FLG_SEP,
- ['~'] = H1_FLG_TOK,
- [127] = H1_FLG_CTL,
-};
-
-
/*
* This function parses a status line between <ptr> and <end>, starting with
* parser state <state>. Only states HTTP_MSG_RPVER, HTTP_MSG_RPVER_SP,
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index cebce22..5721445 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -26,7 +26,7 @@
#include <types/proxy.h>
#include <types/stats.h>
-#include <proto/proto_http.h>
+#include <proto/h1.h>
#include <proto/proxy.h>
#include <proto/server.h>
#include <proto/stats.h>
diff --git a/src/http.c b/src/http.c
new file mode 100644
index 0000000..ad620a9
--- /dev/null
+++ b/src/http.c
@@ -0,0 +1,185 @@
+/*
+ * HTTP semantics
+ *
+ * Copyright 2000-2018 Willy Tarreau <w@1wt.eu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <ctype.h>
+#include <common/config.h>
+#include <common/http.h>
+
+/* It is about twice as fast on recent architectures to lookup a byte in a
+ * table than to perform a boolean AND or OR between two tests. Refer to
+ * RFC2616/RFC5234/RFC7230 for those chars. A token is any ASCII char that is
+ * neither a separator nor a CTL char. An http ver_token is any ASCII which can
+ * be found in an HTTP version, which includes 'H', 'T', 'P', '/', '.' and any
+ * digit. Note: please do not overwrite values in assignment since gcc-2.95
+ * will not handle them correctly. It's worth noting that chars 128..255 are
+ * nothing, not even control chars.
+ */
+const unsigned char http_char_classes[256] = {
+ [ 0] = HTTP_FLG_CTL,
+ [ 1] = HTTP_FLG_CTL,
+ [ 2] = HTTP_FLG_CTL,
+ [ 3] = HTTP_FLG_CTL,
+ [ 4] = HTTP_FLG_CTL,
+ [ 5] = HTTP_FLG_CTL,
+ [ 6] = HTTP_FLG_CTL,
+ [ 7] = HTTP_FLG_CTL,
+ [ 8] = HTTP_FLG_CTL,
+ [ 9] = HTTP_FLG_SPHT | HTTP_FLG_LWS | HTTP_FLG_SEP | HTTP_FLG_CTL,
+ [ 10] = HTTP_FLG_CRLF | HTTP_FLG_LWS | HTTP_FLG_CTL,
+ [ 11] = HTTP_FLG_CTL,
+ [ 12] = HTTP_FLG_CTL,
+ [ 13] = HTTP_FLG_CRLF | HTTP_FLG_LWS | HTTP_FLG_CTL,
+ [ 14] = HTTP_FLG_CTL,
+ [ 15] = HTTP_FLG_CTL,
+ [ 16] = HTTP_FLG_CTL,
+ [ 17] = HTTP_FLG_CTL,
+ [ 18] = HTTP_FLG_CTL,
+ [ 19] = HTTP_FLG_CTL,
+ [ 20] = HTTP_FLG_CTL,
+ [ 21] = HTTP_FLG_CTL,
+ [ 22] = HTTP_FLG_CTL,
+ [ 23] = HTTP_FLG_CTL,
+ [ 24] = HTTP_FLG_CTL,
+ [ 25] = HTTP_FLG_CTL,
+ [ 26] = HTTP_FLG_CTL,
+ [ 27] = HTTP_FLG_CTL,
+ [ 28] = HTTP_FLG_CTL,
+ [ 29] = HTTP_FLG_CTL,
+ [ 30] = HTTP_FLG_CTL,
+ [ 31] = HTTP_FLG_CTL,
+ [' '] = HTTP_FLG_SPHT | HTTP_FLG_LWS | HTTP_FLG_SEP,
+ ['!'] = HTTP_FLG_TOK,
+ ['"'] = HTTP_FLG_SEP,
+ ['#'] = HTTP_FLG_TOK,
+ ['$'] = HTTP_FLG_TOK,
+ ['%'] = HTTP_FLG_TOK,
+ ['&'] = HTTP_FLG_TOK,
+ [ 39] = HTTP_FLG_TOK,
+ ['('] = HTTP_FLG_SEP,
+ [')'] = HTTP_FLG_SEP,
+ ['*'] = HTTP_FLG_TOK,
+ ['+'] = HTTP_FLG_TOK,
+ [','] = HTTP_FLG_SEP,
+ ['-'] = HTTP_FLG_TOK,
+ ['.'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['/'] = HTTP_FLG_SEP | HTTP_FLG_VER,
+ ['0'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['1'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['2'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['3'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['4'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['5'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['6'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['7'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['8'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ ['9'] = HTTP_FLG_TOK | HTTP_FLG_VER | HTTP_FLG_DIG,
+ [':'] = HTTP_FLG_SEP,
+ [';'] = HTTP_FLG_SEP,
+ ['<'] = HTTP_FLG_SEP,
+ ['='] = HTTP_FLG_SEP,
+ ['>'] = HTTP_FLG_SEP,
+ ['?'] = HTTP_FLG_SEP,
+ ['@'] = HTTP_FLG_SEP,
+ ['A'] = HTTP_FLG_TOK,
+ ['B'] = HTTP_FLG_TOK,
+ ['C'] = HTTP_FLG_TOK,
+ ['D'] = HTTP_FLG_TOK,
+ ['E'] = HTTP_FLG_TOK,
+ ['F'] = HTTP_FLG_TOK,
+ ['G'] = HTTP_FLG_TOK,
+ ['H'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['I'] = HTTP_FLG_TOK,
+ ['J'] = HTTP_FLG_TOK,
+ ['K'] = HTTP_FLG_TOK,
+ ['L'] = HTTP_FLG_TOK,
+ ['M'] = HTTP_FLG_TOK,
+ ['N'] = HTTP_FLG_TOK,
+ ['O'] = HTTP_FLG_TOK,
+ ['P'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['Q'] = HTTP_FLG_TOK,
+ ['R'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['S'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['T'] = HTTP_FLG_TOK | HTTP_FLG_VER,
+ ['U'] = HTTP_FLG_TOK,
+ ['V'] = HTTP_FLG_TOK,
+ ['W'] = HTTP_FLG_TOK,
+ ['X'] = HTTP_FLG_TOK,
+ ['Y'] = HTTP_FLG_TOK,
+ ['Z'] = HTTP_FLG_TOK,
+ ['['] = HTTP_FLG_SEP,
+ [ 92] = HTTP_FLG_SEP,
+ [']'] = HTTP_FLG_SEP,
+ ['^'] = HTTP_FLG_TOK,
+ ['_'] = HTTP_FLG_TOK,
+ ['`'] = HTTP_FLG_TOK,
+ ['a'] = HTTP_FLG_TOK,
+ ['b'] = HTTP_FLG_TOK,
+ ['c'] = HTTP_FLG_TOK,
+ ['d'] = HTTP_FLG_TOK,
+ ['e'] = HTTP_FLG_TOK,
+ ['f'] = HTTP_FLG_TOK,
+ ['g'] = HTTP_FLG_TOK,
+ ['h'] = HTTP_FLG_TOK,
+ ['i'] = HTTP_FLG_TOK,
+ ['j'] = HTTP_FLG_TOK,
+ ['k'] = HTTP_FLG_TOK,
+ ['l'] = HTTP_FLG_TOK,
+ ['m'] = HTTP_FLG_TOK,
+ ['n'] = HTTP_FLG_TOK,
+ ['o'] = HTTP_FLG_TOK,
+ ['p'] = HTTP_FLG_TOK,
+ ['q'] = HTTP_FLG_TOK,
+ ['r'] = HTTP_FLG_TOK,
+ ['s'] = HTTP_FLG_TOK,
+ ['t'] = HTTP_FLG_TOK,
+ ['u'] = HTTP_FLG_TOK,
+ ['v'] = HTTP_FLG_TOK,
+ ['w'] = HTTP_FLG_TOK,
+ ['x'] = HTTP_FLG_TOK,
+ ['y'] = HTTP_FLG_TOK,
+ ['z'] = HTTP_FLG_TOK,
+ ['{'] = HTTP_FLG_SEP,
+ ['|'] = HTTP_FLG_TOK,
+ ['}'] = HTTP_FLG_SEP,
+ ['~'] = HTTP_FLG_TOK,
+ [127] = HTTP_FLG_CTL,
+};
+
+const struct ist http_known_methods[HTTP_METH_OTHER] = {
+ [HTTP_METH_OPTIONS] = IST("OPTIONS"),
+ [HTTP_METH_GET] = IST("GET"),
+ [HTTP_METH_HEAD] = IST("HEAD"),
+ [HTTP_METH_POST] = IST("POST"),
+ [HTTP_METH_PUT] = IST("PUT"),
+ [HTTP_METH_DELETE] = IST("DELETE"),
+ [HTTP_METH_TRACE] = IST("TRACE"),
+ [HTTP_METH_CONNECT] = IST("CONNECT"),
+};
+
+/*
+ * returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
+ * ones.
+ */
+enum http_meth_t find_http_meth(const char *str, const int len)
+{
+ const struct ist m = ist2(str, len);
+
+ if (isteq(m, ist("GET"))) return HTTP_METH_GET;
+ else if (isteq(m, ist("HEAD"))) return HTTP_METH_HEAD;
+ else if (isteq(m, ist("POST"))) return HTTP_METH_POST;
+ else if (isteq(m, ist("CONNECT"))) return HTTP_METH_CONNECT;
+ else if (isteq(m, ist("PUT"))) return HTTP_METH_PUT;
+ else if (isteq(m, ist("OPTIONS"))) return HTTP_METH_OPTIONS;
+ else if (isteq(m, ist("DELETE"))) return HTTP_METH_DELETE;
+ else if (isteq(m, ist("TRACE"))) return HTTP_METH_TRACE;
+ else return HTTP_METH_OTHER;
+}
diff --git a/src/lb_map.c b/src/lb_map.c
index 54569b0..2d8faa9 100644
--- a/src/lb_map.c
+++ b/src/lb_map.c
@@ -20,8 +20,6 @@
#include <proto/backend.h>
#include <proto/lb_map.h>
-#include <proto/proto_http.h>
-#include <proto/proto_tcp.h>
#include <proto/queue.h>
/* this function updates the map according to server <srv>'s new state.
diff --git a/src/log.c b/src/log.c
index 3bd2285..11e75ec 100644
--- a/src/log.c
+++ b/src/log.c
@@ -36,7 +36,7 @@
#include <proto/applet.h>
#include <proto/cli.h>
#include <proto/frontend.h>
-#include <proto/proto_http.h>
+#include <proto/h1.h>
#include <proto/log.h>
#include <proto/sample.h>
#include <proto/stream.h>
diff --git a/src/peers.c b/src/peers.c
index 1fefa94..50aee87 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -39,8 +39,6 @@
#include <proto/log.h>
#include <proto/hdr_idx.h>
#include <proto/mux_pt.h>
-#include <proto/proto_tcp.h>
-#include <proto/proto_http.h>
#include <proto/proxy.h>
#include <proto/session.h>
#include <proto/stream.h>
diff --git a/src/proto_http.c b/src/proto_http.c
index b97c6bf..b153b14 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -488,55 +488,6 @@
}
/*
- * We have 26 list of methods (1 per first letter), each of which can have
- * up to 3 entries (2 valid, 1 null).
- */
-struct http_method_desc {
- enum http_meth_t meth;
- int len;
- const char text[8];
-};
-
-const struct http_method_desc http_methods[26][3] = {
- ['C' - 'A'] = {
- [0] = { .meth = HTTP_METH_CONNECT , .len=7, .text="CONNECT" },
- },
- ['D' - 'A'] = {
- [0] = { .meth = HTTP_METH_DELETE , .len=6, .text="DELETE" },
- },
- ['G' - 'A'] = {
- [0] = { .meth = HTTP_METH_GET , .len=3, .text="GET" },
- },
- ['H' - 'A'] = {
- [0] = { .meth = HTTP_METH_HEAD , .len=4, .text="HEAD" },
- },
- ['O' - 'A'] = {
- [0] = { .meth = HTTP_METH_OPTIONS , .len=7, .text="OPTIONS" },
- },
- ['P' - 'A'] = {
- [0] = { .meth = HTTP_METH_POST , .len=4, .text="POST" },
- [1] = { .meth = HTTP_METH_PUT , .len=3, .text="PUT" },
- },
- ['T' - 'A'] = {
- [0] = { .meth = HTTP_METH_TRACE , .len=5, .text="TRACE" },
- },
- /* rest is empty like this :
- * [0] = { .meth = HTTP_METH_OTHER , .len=0, .text="" },
- */
-};
-
-const struct http_method_name http_known_methods[HTTP_METH_OTHER] = {
- [HTTP_METH_OPTIONS] = { "OPTIONS", 7 },
- [HTTP_METH_GET] = { "GET", 3 },
- [HTTP_METH_HEAD] = { "HEAD", 4 },
- [HTTP_METH_POST] = { "POST", 4 },
- [HTTP_METH_PUT] = { "PUT", 3 },
- [HTTP_METH_DELETE] = { "DELETE", 6 },
- [HTTP_METH_TRACE] = { "TRACE", 5 },
- [HTTP_METH_CONNECT] = { "CONNECT", 7 },
-};
-
-/*
* Adds a header and its CRLF at the tail of the message's buffer, just before
* the last CRLF.
* The header is also automatically added to the index <hdr_idx>, and the end
@@ -959,28 +910,6 @@
stream_int_retnclose(&s->si[0], msg);
}
-/*
- * returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
- * ones.
- */
-enum http_meth_t find_http_meth(const char *str, const int len)
-{
- unsigned char m;
- const struct http_method_desc *h;
-
- m = ((unsigned)*str - 'A');
-
- if (m < 26) {
- for (h = http_methods[m]; h->len > 0; h++) {
- if (unlikely(h->len != len))
- continue;
- if (likely(memcmp(str, h->text, h->len) == 0))
- return h->meth;
- };
- }
- return HTTP_METH_OTHER;
-}
-
/* Parse the URI from the given transaction (which is assumed to be in request
* phase) and look for the "/" beginning the PATH. If not found, return NULL.
* It is returned otherwise.
diff --git a/src/sample.c b/src/sample.c
index e3dea1b..138390d 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -20,6 +20,7 @@
#include <common/chunk.h>
#include <common/hash.h>
+#include <common/http.h>
#include <common/standard.h>
#include <common/uri_auth.h>
#include <common/base64.h>
@@ -27,7 +28,6 @@
#include <proto/arg.h>
#include <proto/auth.h>
#include <proto/log.h>
-#include <proto/proto_http.h>
#include <proto/proxy.h>
#include <proto/sample.h>
#include <proto/stick_table.h>
@@ -749,7 +749,7 @@
else if (smp->data.u.meth.meth < HTTP_METH_OTHER) {
/* The method is known, copy the pointer containing the string. */
meth = smp->data.u.meth.meth;
- smp->data.u.str.area = http_known_methods[meth].name;
+ smp->data.u.str.area = http_known_methods[meth].ptr;
smp->data.u.str.data = http_known_methods[meth].len;
smp->flags |= SMP_F_CONST;
smp->data.type = SMP_T_STR;
diff --git a/src/session.c b/src/session.c
index c9d50df..3454925 100644
--- a/src/session.c
+++ b/src/session.c
@@ -13,6 +13,7 @@
#include <common/config.h>
#include <common/buffer.h>
#include <common/debug.h>
+#include <common/http.h>
#include <common/memory.h>
#include <types/global.h>
@@ -21,7 +22,6 @@
#include <proto/connection.h>
#include <proto/listener.h>
#include <proto/log.h>
-#include <proto/proto_http.h>
#include <proto/proxy.h>
#include <proto/session.h>
#include <proto/stream.h>
diff --git a/src/stats.c b/src/stats.c
index 4cea776..da960f5 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -28,6 +28,7 @@
#include <common/compat.h>
#include <common/config.h>
#include <common/debug.h>
+#include <common/http.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <common/standard.h>
@@ -57,7 +58,6 @@
#include <proto/pipe.h>
#include <proto/listener.h>
#include <proto/map.h>
-#include <proto/proto_http.h>
#include <proto/proxy.h>
#include <proto/sample.h>
#include <proto/session.h>
diff --git a/src/vars.c b/src/vars.c
index 5787cf6..905e20c 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -1,6 +1,7 @@
#include <ctype.h>
#include <common/cfgparse.h>
+#include <common/http.h>
#include <common/mini-clist.h>
#include <types/vars.h>