[MINOR] removed the SN_POST flag and string checks on method

Now that hreq.meth is known, use it everywhere a method is required.
This commit is contained in:
Willy Tarreau 2006-12-17 13:50:27 +01:00
parent 53b6c74d06
commit 921d7c0a70
2 changed files with 6 additions and 21 deletions

View File

@ -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 */

View File

@ -907,7 +907,6 @@ int process_cli(struct session *t)
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 @@ int process_cli(struct session *t)
/* 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 ? */
@ -957,19 +954,7 @@ int process_cli(struct session *t)
*/
/*
* 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 @@ int process_cli(struct session *t)
* 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 @@ int process_srv(struct session *t)
/* 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 @@ int process_srv(struct session *t)
* 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 @@ void get_srv_from_appsession(struct session *t, const char *begin, const char *e
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;