|
@@ -0,0 +1,78 @@
|
|
1
|
+From bcd033699c5a4904967652de4980e4f35f17ee34 Mon Sep 17 00:00:00 2001
|
|
2
|
+From: Willy Tarreau <w@1wt.eu>
|
|
3
|
+Date: Thu, 3 Sep 2015 17:15:21 +0200
|
|
4
|
+Subject: [PATCH 14/16] BUG/MINOR: http: remove stupid HTTP_METH_NONE entry
|
|
5
|
+
|
|
6
|
+When converting the "method" fetch to a string, we used to get an empty
|
|
7
|
+string if the first character was not an upper case. This was caused by
|
|
8
|
+the lookup function which returns HTTP_METH_NONE when a lookup is not
|
|
9
|
+possible, and this method being mapped to an empty string in the array.
|
|
10
|
+
|
|
11
|
+This is a totally stupid mechanism, there's no reason for having the
|
|
12
|
+result depend on the first char. In fact the message parser already
|
|
13
|
+checks that the syntax matches an HTTP token so we can only land there
|
|
14
|
+with a valid token, hence only HTTP_METH_OTHER should be returned.
|
|
15
|
+
|
|
16
|
+This fix should be backported to all actively supported branches.
|
|
17
|
+(cherry picked from commit b7ce424be2bc9df73a3b971fa9dd6daea0332bf1)
|
|
18
|
+---
|
|
19
|
+ include/types/proto_http.h | 1 -
|
|
20
|
+ src/proto_http.c | 11 ++++-------
|
|
21
|
+ 2 files changed, 4 insertions(+), 8 deletions(-)
|
|
22
|
+
|
|
23
|
+diff --git a/include/types/proto_http.h b/include/types/proto_http.h
|
|
24
|
+index a5a5d31..dbce972 100644
|
|
25
|
+--- a/include/types/proto_http.h
|
|
26
|
++++ b/include/types/proto_http.h
|
|
27
|
+@@ -219,7 +219,6 @@ enum {
|
|
28
|
+
|
|
29
|
+ /* Known HTTP methods */
|
|
30
|
+ enum http_meth_t {
|
|
31
|
+- HTTP_METH_NONE = 0,
|
|
32
|
+ HTTP_METH_OPTIONS,
|
|
33
|
+ HTTP_METH_GET,
|
|
34
|
+ HTTP_METH_HEAD,
|
|
35
|
+diff --git a/src/proto_http.c b/src/proto_http.c
|
|
36
|
+index 02dc42b..46694cb 100644
|
|
37
|
+--- a/src/proto_http.c
|
|
38
|
++++ b/src/proto_http.c
|
|
39
|
+@@ -361,12 +361,11 @@ const struct http_method_desc http_methods[26][3] = {
|
|
40
|
+ [0] = { .meth = HTTP_METH_TRACE , .len=5, .text="TRACE" },
|
|
41
|
+ },
|
|
42
|
+ /* rest is empty like this :
|
|
43
|
+- * [1] = { .meth = HTTP_METH_NONE , .len=0, .text="" },
|
|
44
|
++ * [0] = { .meth = HTTP_METH_OTHER , .len=0, .text="" },
|
|
45
|
+ */
|
|
46
|
+ };
|
|
47
|
+
|
|
48
|
+ const struct http_method_name http_known_methods[HTTP_METH_OTHER] = {
|
|
49
|
+- [HTTP_METH_NONE] = { "", 0 },
|
|
50
|
+ [HTTP_METH_OPTIONS] = { "OPTIONS", 7 },
|
|
51
|
+ [HTTP_METH_GET] = { "GET", 3 },
|
|
52
|
+ [HTTP_METH_HEAD] = { "HEAD", 4 },
|
|
53
|
+@@ -793,8 +792,8 @@ struct chunk *http_error_message(struct session *s, int msgnum)
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ /*
|
|
57
|
+- * returns HTTP_METH_NONE if there is nothing valid to read (empty or non-text
|
|
58
|
+- * string), HTTP_METH_OTHER for unknown methods, or the identified method.
|
|
59
|
++ * returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
|
|
60
|
++ * ones.
|
|
61
|
+ */
|
|
62
|
+ enum http_meth_t find_http_meth(const char *str, const int len)
|
|
63
|
+ {
|
|
64
|
+@@ -810,10 +809,8 @@ enum http_meth_t find_http_meth(const char *str, const int len)
|
|
65
|
+ if (likely(memcmp(str, h->text, h->len) == 0))
|
|
66
|
+ return h->meth;
|
|
67
|
+ };
|
|
68
|
+- return HTTP_METH_OTHER;
|
|
69
|
+ }
|
|
70
|
+- return HTTP_METH_NONE;
|
|
71
|
+-
|
|
72
|
++ return HTTP_METH_OTHER;
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ /* Parse the URI from the given transaction (which is assumed to be in request
|
|
76
|
+--
|
|
77
|
+2.4.6
|
|
78
|
+
|