* Vary values, and the one used for per-condition checks in a chain.
*/
#define VARY_KEY "rewrite-Vary"
-#define VARY_KEY_THIS "rewrite-Vary-this"
/* remembered mime-type for [T=...] */
#define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"
backrefinfo *briRR;
backrefinfo *briRC;
const char *uri;
+ const char *vary_this;
char *perdir;
} exp_ctx;
/*
* lookup a HTTP header and set VARY note
*/
-static const char *lookup_header(request_rec *r, const char *name)
+static const char *lookup_header(const char *name, exp_ctx *ctx)
{
- const char *val = apr_table_get(r->headers_in, name);
+ const char *val = apr_table_get(ctx->r->headers_in, name);
if (val) {
- apr_table_merge(r->notes, VARY_KEY_THIS, name);
+ ctx->vary_this = ctx->vary_this
+ ? apr_pstrcat(ctx->r->pool, ctx->vary_this, ", ",
+ name, NULL)
+ : apr_pstrdup(ctx->r->pool, name);
}
return val;
const char *path;
if (!strncasecmp(var, "HTTP", 4)) {
- result = lookup_header(r, var+5);
+ result = lookup_header(var+5, ctx);
}
else if (!strncasecmp(var, "LA-U", 4)) {
if (ctx->uri && subreq_ok(r)) {
case 'S':
if (!strcmp(var, "HTTP_HOST")) {
- result = lookup_header(r, "Host");
+ result = lookup_header("Host", ctx);
}
break;
case 'E':
if (*var == 'H' && !strcmp(var, "HTTP_ACCEPT")) {
- result = lookup_header(r, "Accept");
+ result = lookup_header("Accept", ctx);
}
else if (!strcmp(var, "THE_REQUEST")) {
result = r->the_request;
case 'K':
if (!strcmp(var, "HTTP_COOKIE")) {
- result = lookup_header(r, "Cookie");
+ result = lookup_header("Cookie", ctx);
}
break;
case 'P':
if (!strcmp(var, "HTTP_REFERER")) {
- result = lookup_header(r, "Referer");
+ result = lookup_header("Referer", ctx);
}
break;
case 14:
if (*var == 'H' && !strcmp(var, "HTTP_FORWARDED")) {
- result = lookup_header(r, "Forwarded");
+ result = lookup_header("Forwarded", ctx);
}
else if (!strcmp(var, "REQUEST_METHOD")) {
result = r->method;
switch (var[7]) {
case 'E':
if (!strcmp(var, "HTTP_USER_AGENT")) {
- result = lookup_header(r, "User-Agent");
+ result = lookup_header("User-Agent", ctx);
}
break;
case 21:
if (!strcmp(var, "HTTP_PROXY_CONNECTION")) {
- result = lookup_header(r, "Proxy-Connection");
+ result = lookup_header("Proxy-Connection", ctx);
}
break;
}
* Else create the RewriteRule `regsubinfo' structure which
* holds the substitution information.
*/
- ctx = apr_palloc(r->pool, sizeof(*ctx));
- ctx->r = r;
- ctx->perdir = perdir;
- ctx->uri = uri;
+ ctx = apr_palloc(r->pool, sizeof(*ctx));
+ ctx->r = r;
+ ctx->perdir = perdir;
+ ctx->uri = uri;
+ ctx->vary_this = NULL;
ctx->briRR = apr_palloc(r->pool, sizeof(*ctx->briRR));
if (!rc && (p->flags & RULEFLAG_NOTMATCH)) {
/* One condition is false, but another can be
* still true, so we have to continue...
*/
- apr_table_unset(r->notes, VARY_KEY_THIS);
+ ctx->vary_this = NULL;
continue;
}
else {
break;
}
}
- vary = apr_table_get(r->notes, VARY_KEY_THIS);
- if (vary != NULL) {
- apr_table_merge(r->notes, VARY_KEY, vary);
- apr_table_unset(r->notes, VARY_KEY_THIS);
+ if (ctx->vary_this) {
+ apr_table_merge(r->notes, VARY_KEY, ctx->vary_this);
+ ctx->vary_this = NULL;
}
}
/* if any condition fails the complete rule fails */
if (failed) {
apr_table_unset(r->notes, VARY_KEY);
- apr_table_unset(r->notes, VARY_KEY_THIS);
+ ctx->vary_this = NULL;
return 0;
}