Add request.environment[] conditional
This commit is contained in:
parent
fdf881311d
commit
eff8ed5e50
|
@ -54,7 +54,8 @@ typedef enum {
|
|||
|
||||
/* needs a key */
|
||||
LI_COMP_REQUEST_HEADER, /**< needs lowercase key, enforced by li_condition_lvalue_new */
|
||||
LI_COMP_RESPONSE_HEADER, /**< needs lowercase key, enforced by li_condition_lvalue_new */
|
||||
LI_COMP_RESPONSE_HEADER, /**< needs lowercase key, enforced by li_condition_lvalue_new */
|
||||
LI_COMP_ENVIRONMENT,
|
||||
|
||||
LI_COMP_UNKNOWN
|
||||
} liCondLValue;
|
||||
|
|
|
@ -262,6 +262,7 @@ const char* li_cond_lvalue_to_string(liCondLValue t) {
|
|||
case LI_COMP_RESPONSE_STATUS: return "response.status";
|
||||
case LI_COMP_REQUEST_HEADER: return "request.header";
|
||||
case LI_COMP_RESPONSE_HEADER: return "response.header";
|
||||
case LI_COMP_ENVIRONMENT: return "request.environment";
|
||||
case LI_COMP_UNKNOWN: return "<unknown>";
|
||||
}
|
||||
|
||||
|
@ -293,6 +294,8 @@ liCondLValue li_cond_lvalue_from_string(const gchar *str, guint len) {
|
|||
return LI_COMP_REQUEST_CONTENT_LENGTH;
|
||||
else if (strncmp(c, "header", len) == 0)
|
||||
return LI_COMP_REQUEST_HEADER;
|
||||
else if (strncmp(c, "environment", len) == 0 || strncmp(c, "env", len) == 0)
|
||||
return LI_COMP_ENVIRONMENT;
|
||||
else if (strncmp(c, "is_handled", len) == 0)
|
||||
return LI_COMP_REQUEST_IS_HANDLED;
|
||||
} else if (g_str_has_prefix(c, "physical.")) {
|
||||
|
@ -412,6 +415,9 @@ static liHandlerResult li_condition_check_eval_string(liVRequest *vr, liConditio
|
|||
li_http_header_get_all(con->wrk->tmp_str, vr->response.headers, GSTR_LEN(cond->lvalue->key));
|
||||
val = con->wrk->tmp_str->str;
|
||||
break;
|
||||
case LI_COMP_ENVIRONMENT:
|
||||
val = li_environment_get(&vr->env, GSTR_LEN(cond->lvalue->key));
|
||||
break;
|
||||
case LI_COMP_REQUEST_CONTENT_LENGTH:
|
||||
g_string_printf(con->wrk->tmp_str, "%"L_GOFFSET_FORMAT, vr->request.content_length);
|
||||
val = con->wrk->tmp_str->str;
|
||||
|
@ -600,6 +606,9 @@ static liHandlerResult li_condition_check_eval_ip(liVRequest *vr, liCondition *c
|
|||
li_http_header_get_all(con->wrk->tmp_str, vr->response.headers, GSTR_LEN(cond->lvalue->key));
|
||||
val = con->wrk->tmp_str->str;
|
||||
break;
|
||||
case LI_COMP_ENVIRONMENT:
|
||||
val = li_environment_get(&vr->env, GSTR_LEN(cond->lvalue->key))->str;
|
||||
break;
|
||||
case LI_COMP_PHYSICAL_SIZE:
|
||||
case LI_COMP_REQUEST_CONTENT_LENGTH:
|
||||
case LI_COMP_RESPONSE_STATUS:
|
||||
|
|
|
@ -866,6 +866,13 @@
|
|||
}
|
||||
lvalue = li_condition_lvalue_new(LI_COMP_REQUEST_HEADER, li_value_extract(k).string);
|
||||
}
|
||||
else if (g_str_equal(str, "environment") || g_str_equal(str, "env")) {
|
||||
if (k == NULL) {
|
||||
WARNING(srv, "%s", "environment conditional needs a key");
|
||||
return FALSE;
|
||||
}
|
||||
lvalue = li_condition_lvalue_new(LI_COMP_ENVIRONMENT, li_value_extract(k).string);
|
||||
}
|
||||
else {
|
||||
WARNING(srv, "unkown lvalue for condition: %s", n->data.string->str);
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue