[core] expose request.raw_path as condition variable

personal/stbuehler/wip
Stefan Bühler 9 years ago
parent e168e0653c
commit 4c741ce853

@ -299,6 +299,7 @@
| request.remoteip | ip address of the client |
| request.remoteport | port number of the client, -1 for unix sockets |
| request.path | the _path_ part of the requested url. not including the querystring. |
| request.raw_path | the raw _path_ part (not urldecoded, not simplified) of the requested url. not including the querystring. |
| request.host | requested hostname |
| request.scheme | scheme of the request. "http" or "https" |
| request.query | the _querystring_ of the requested url |

@ -14,7 +14,7 @@
* simple text. can contain special characters $ and % only when they are escaped with \ - remember, that the \ has to be escaped too for the config, so you'll probably have to use \\ to escape. You are allowed to escape ? too (used for special "split" in rewrite).
* "%" capture references (previous matching regular expression conditional); either followed by a single digit, or a range (see below for range syntax)
* "$" capture references (depends on action); either followed by a single digit, or a range (see below for range syntax)
* "%" references to "condition variables":core_config.html#core_connfig__condition_vars, for example: @%{req.path}@; the conditional can be prefixed with "enc:" (@%{enc:req.path}@), in which case the value will be urlencoded.
* "%" references to "condition variables":core_config.html#core_config__condition_vars, for example: @%{req.path}@; the conditional can be prefixed with "enc:" (@%{enc:req.path}@), in which case the value will be urlencoded.
</textile>
</section>

@ -42,6 +42,7 @@ typedef enum {
LI_COMP_REQUEST_REMOTEIP,
LI_COMP_REQUEST_REMOTEPORT,
LI_COMP_REQUEST_PATH,
LI_COMP_REQUEST_RAW_PATH,
LI_COMP_REQUEST_HOST,
LI_COMP_REQUEST_SCHEME,
LI_COMP_REQUEST_QUERY_STRING,

@ -7,6 +7,7 @@ static const liConditionValueType cond_value_hints[] = {
/* LI_COMP_REQUEST_REMOTEIP: */ LI_COND_VALUE_HINT_SOCKADDR,
/* LI_COMP_REQUEST_REMOTEPORT: */ LI_COND_VALUE_HINT_NUMBER,
/* LI_COMP_REQUEST_PATH: */ LI_COND_VALUE_HINT_STRING,
/* LI_COMP_REQUEST_RAW_PATH: */ LI_COND_VALUE_HINT_STRING,
/* LI_COMP_REQUEST_HOST: */ LI_COND_VALUE_HINT_ANY,
/* LI_COMP_REQUEST_SCHEME: */ LI_COND_VALUE_HINT_STRING,
/* LI_COMP_REQUEST_QUERY_STRING: */ LI_COND_VALUE_HINT_ANY,
@ -95,6 +96,10 @@ liHandlerResult li_condition_get_value(GString *tmpstr, liVRequest *vr, liCondit
res->match_type = LI_COND_VALUE_HINT_STRING;
res->data.str = vr->request.uri.path->str;
break;
case LI_COMP_REQUEST_RAW_PATH:
res->match_type = LI_COND_VALUE_HINT_STRING;
res->data.str = vr->request.uri.raw_path->str;
break;
case LI_COMP_REQUEST_HOST:
res->match_type = LI_COND_VALUE_HINT_STRING;
res->data.str = vr->request.uri.host->str;
@ -465,6 +470,7 @@ const char* li_cond_lvalue_to_string(liCondLValue t) {
case LI_COMP_REQUEST_REMOTEIP: return "request.remoteip";
case LI_COMP_REQUEST_REMOTEPORT: return "request.remoteport";
case LI_COMP_REQUEST_PATH: return "request.path";
case LI_COMP_REQUEST_RAW_PATH: return "request.raw_path";
case LI_COMP_REQUEST_HOST: return "request.host";
case LI_COMP_REQUEST_SCHEME: return "request.scheme";
case LI_COMP_REQUEST_QUERY_STRING: return "request.query";
@ -512,6 +518,8 @@ liCondLValue li_cond_lvalue_from_string(const gchar *str, guint len) {
return LI_COMP_REQUEST_REMOTEPORT;
else if (strncmp(c, "path", len) == 0)
return LI_COMP_REQUEST_PATH;
else if (strncmp(c, "raw_path", len) == 0)
return LI_COMP_REQUEST_RAW_PATH;
else if (strncmp(c, "host", len) == 0)
return LI_COMP_REQUEST_HOST;
else if (strncmp(c, "scheme", len) == 0)

Loading…
Cancel
Save