[MINOR] removed the SN_POST flag and string checks on method
Now that hreq.meth is known, use it everywhere a method is required.
diff --git a/include/types/session.h b/include/types/session.h
index a153019..9a04994 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -45,7 +45,7 @@
#define SN_CLALLOW 0x00000004 /* a client header matches an allow regex */
#define SN_SVDENY 0x00000008 /* a server header matches a deny regex */
#define SN_SVALLOW 0x00000010 /* a server header matches an allow regex */
-#define SN_POST 0x00000020 /* the request was an HTTP POST */
+#define SN_UNUSED_1 0x00000020 /* unused bit */
/* session flags dedicated to cookies : bits values 0x40, 0x80 (0-3 shift 6) */
#define SN_CK_NONE 0x00000000 /* this session had no cookie */
diff --git a/src/proto_http.c b/src/proto_http.c
index e6e4ca7..b2d6209 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -907,7 +907,6 @@
t->hreq.start.str = req->data + t->hreq.sor; /* start of the REQURI */
t->hreq.start.len = t->hreq.hdr_idx.v[t->hreq.hdr_idx.v[0].next].len; /* end of the REQURI */
-
t->hreq.meth = find_http_meth(t->hreq.start.str, t->hreq.start.len);
do {
@@ -920,8 +919,6 @@
/* the start line might have been modified */
t->hreq.start.len = t->hreq.hdr_idx.v[t->hreq.hdr_idx.v[0].next].len;
t->hreq.meth = find_http_meth(t->hreq.start.str, t->hreq.start.len);
-
- t->hreq.meth = find_http_meth(t->hreq.start.str, t->hreq.start.len);
}
/* has the request been denied ? */
@@ -956,20 +953,8 @@
* may have separate values for ->fe, ->fi and ->be.
*/
-
- /*
- * 3: save a pointer to the first line as the request, and
- * check the method (needed for cookies).
- */
- t->hreq.start.str = req->data + t->hreq.sor; /* start of the REQURI */
- t->hreq.start.len = t->hreq.hdr_idx.v[t->hreq.hdr_idx.v[0].next].len; /* end of the REQURI */
- if (t->hreq.meth == HTTP_METH_POST) {
- /* this is a POST request, which is not cacheable by default */
- t->flags |= SN_POST;
- }
-
/*
* 4: the appsession cookie was looked up very early in 1.2,
@@ -1004,10 +989,10 @@
* 6: check if the user tries to access a protected URI.
*/
if (t->be->uri_auth != NULL
+ && t->hreq.meth == HTTP_METH_GET
&& t->hreq.start.len >= t->be->uri_auth->uri_len + 4) { /* +4 for "GET /" */
if (!memcmp(t->hreq.start.str + 4,
- t->be->uri_auth->uri_prefix, t->be->uri_auth->uri_len)
- && !memcmp(t->hreq.start.str, "GET ", 4)) {
+ t->be->uri_auth->uri_prefix, t->be->uri_auth->uri_len)) {
struct user_auth *user;
int authenticated;
char *h;
@@ -1809,7 +1794,7 @@
/* we'll have something else to do here : add new headers ... */
if ((t->srv) && !(t->flags & SN_DIRECT) && (t->be->options & PR_O_COOK_INS) &&
- (!(t->be->options & PR_O_COOK_POST) || (t->flags & SN_POST))) {
+ (!(t->be->options & PR_O_COOK_POST) || (t->hreq.meth == HTTP_METH_POST))) {
/* the server is known, it's not the one the client requested, we have to
* insert a set-cookie here, except if we want to insert only on POST
* requests and this one isn't. Note that servers which don't have cookies
@@ -1927,7 +1912,7 @@
* unless the response includes appropriate
* Cache-Control or Expires header fields."
*/
- if (!(t->flags & SN_POST) && (t->be->options & PR_O_CHK_CACHE))
+ if (!(t->hreq.meth == HTTP_METH_POST) && (t->be->options & PR_O_CHK_CACHE))
t->flags |= SN_CACHEABLE | SN_CACHE_COOK;
break;
default:
@@ -3520,7 +3505,7 @@
char *request_line;
if (t->be->appsession_name == NULL ||
- (memcmp(begin, "GET ", 4) != 0 && memcmp(begin, "POST ", 5) != 0) ||
+ (t->hreq.meth != HTTP_METH_GET && t->hreq.meth != HTTP_METH_POST) ||
(request_line = memchr(begin, ';', end - begin)) == NULL ||
((1 + t->be->appsession_name_len + 1 + t->be->appsession_len) > (end - request_line)))
return;