MCPcopy Create free account
hub / github.com/apache/httpd / lookup_variable

Function lookup_variable

modules/mappers/mod_rewrite.c:1975–2365  ·  view source on GitHub ↗

* generic variable lookup */

Source from the content-addressed store, hash-verified

1973 * generic variable lookup
1974 */
1975static char *lookup_variable(char *var, rewrite_ctx *ctx)
1976{
1977 const char *result;
1978 request_rec *r = ctx->r;
1979 apr_size_t varlen = strlen(var);
1980
1981 /* fast exit */
1982 if (varlen < 4) {
1983 return "";
1984 }
1985
1986 result = NULL;
1987
1988 /* fast tests for variable length variables (sic) first */
1989 if (var[3] == ':') {
1990 if (var[4] && !strncasecmp(var, "ENV", 3)) {
1991 var += 4;
1992 result = apr_table_get(r->notes, var);
1993
1994 if (!result) {
1995 result = apr_table_get(r->subprocess_env, var);
1996 }
1997 if (!result) {
1998 result = getenv(var);
1999 }
2000 }
2001 else if (var[4] && !strncasecmp(var, "SSL", 3)) {
2002 result = ap_ssl_var_lookup(r->pool, r->server, r->connection, r,
2003 var + 4);
2004 }
2005 }
2006 else if (var[4] == ':') {
2007 if (var[5]) {
2008 request_rec *rr;
2009 const char *path;
2010
2011 if (!strncasecmp(var, "HTTP", 4)) {
2012 result = lookup_header(var+5, ctx);
2013 }
2014 else if (!strncasecmp(var, "LA-U", 4)) {
2015 if (ctx->uri && subreq_ok(r)) {
2016 path = ctx->perdir ? la_u(ctx) : ctx->uri;
2017 rr = ap_sub_req_lookup_uri(path, r, NULL);
2018 ctx->r = rr;
2019 result = apr_pstrdup(r->pool, lookup_variable(var+5, ctx));
2020 ctx->r = r;
2021 ap_destroy_sub_req(rr);
2022
2023 rewritelog(r, 5, ctx->perdir, "lookahead: path=%s var=%s "
2024 "-> val=%s", path, var+5, result);
2025
2026 return (char *)result;
2027 }
2028 }
2029 else if (!strncasecmp(var, "LA-F", 4)) {
2030 if (ctx->uri && subreq_ok(r)) {
2031 path = ctx->uri;
2032 if (ctx->perdir && *path == '/') {

Callers 1

do_expandFunction · 0.85

Calls 15

ap_ssl_var_lookupFunction · 0.85
lookup_headerFunction · 0.85
la_uFunction · 0.85
ap_sub_req_lookup_uriFunction · 0.85
ap_destroy_sub_reqFunction · 0.85
ap_get_module_configFunction · 0.85
ap_sub_req_lookup_fileFunction · 0.85
ap_str_toupperFunction · 0.85
ap_ssl_conn_is_sslFunction · 0.85
ap_get_server_portFunction · 0.85
ap_get_remote_hostFunction · 0.85

Tested by

no test coverage detected