Browse Source

[core] Add phys.docroot and phys.pathinfo

personal/stbuehler/wip
Stefan Bühler 12 years ago
parent
commit
177fc95219
  1. 2
      include/lighttpd/condition.h
  2. 16
      src/main/condition.c

2
include/lighttpd/condition.h

@ -53,6 +53,8 @@ typedef enum {
LI_COMP_PHYSICAL_SIZE,
LI_COMP_PHYSICAL_ISDIR,
LI_COMP_PHYSICAL_ISFILE,
LI_COMP_PHYSICAL_DOCROOT,
LI_COMP_PHYSICAL_PATHINFO,
LI_COMP_RESPONSE_STATUS,
/* needs a key */

16
src/main/condition.c

@ -19,6 +19,8 @@ static const liConditionValueType cond_value_hints[] = {
/* LI_COMP_PHYSICAL_ISDIR: */ LI_COND_VALUE_HINT_BOOL,
/* LI_COMP_PHYSICAL_ISFILE: */ LI_COND_VALUE_HINT_BOOL,
/* LI_COMP_RESPONSE_STATUS: */ LI_COND_VALUE_HINT_NUMBER,
/* LI_COMP_PHYSICAL_DOCROOT: */ LI_COND_VALUE_HINT_STRING,
/* LI_COMP_PHYSICAL_PATHINFO: */ LI_COND_VALUE_HINT_STRING,
/* LI_COMP_REQUEST_HEADER: */ LI_COND_VALUE_HINT_ANY,
/* LI_COMP_RESPONSE_HEADER: */ LI_COND_VALUE_HINT_ANY,
@ -157,6 +159,14 @@ liHandlerResult li_condition_get_value(liVRequest *vr, liConditionLValue *lvalue
res->data.number = (gint64) st.st_size;
}
break;
case LI_COMP_PHYSICAL_DOCROOT:
res->match_type = LI_COND_VALUE_HINT_STRING;
res->data.str = vr->physical.doc_root->str;
break;
case LI_COMP_PHYSICAL_PATHINFO:
res->match_type = LI_COND_VALUE_HINT_STRING;
res->data.str = vr->physical.pathinfo->str;
break;
case LI_COMP_RESPONSE_STATUS:
VREQUEST_WAIT_FOR_RESPONSE_HEADERS(vr);
res->match_type = LI_COND_VALUE_HINT_NUMBER;
@ -466,6 +476,8 @@ const char* li_cond_lvalue_to_string(liCondLValue t) {
case LI_COMP_PHYSICAL_SIZE: return "physical.size";
case LI_COMP_PHYSICAL_ISDIR: return "physical.is_dir";
case LI_COMP_PHYSICAL_ISFILE: return "physical.is_file";
case LI_COMP_PHYSICAL_DOCROOT: return "physical.docroot";
case LI_COMP_PHYSICAL_PATHINFO: return "physical.pathinfo";
case LI_COMP_RESPONSE_STATUS: return "response.status";
case LI_COMP_REQUEST_HEADER: return "request.header";
case LI_COMP_RESPONSE_HEADER: return "response.header";
@ -537,6 +549,10 @@ liCondLValue li_cond_lvalue_from_string(const gchar *str, guint len) {
return LI_COMP_PHYSICAL_ISFILE;
else if (strncmp(c, "is_dir", len) == 0)
return LI_COMP_PHYSICAL_ISDIR;
else if (strncmp(c, "docroot", len) == 0)
return LI_COMP_PHYSICAL_DOCROOT;
else if (strncmp(c, "pathinfo", len) == 0)
return LI_COMP_PHYSICAL_PATHINFO;
} else if (g_str_has_prefix(c, "resp")) {
if (g_str_has_prefix(c, "resp.")) {
c += sizeof("resp.")-1;

Loading…
Cancel
Save