in native/apache-2.0/mod_jk.c [4048:4204]
static int jk_map_to_storage(request_rec * r)
{
jk_server_conf_t *conf;
jk_request_conf_t *rconf = ap_get_module_config(r->request_config, &jk_module);
if (rconf == NULL) {
rconf = apr_palloc(r->pool, sizeof(jk_request_conf_t));
rconf->jk_handled = JK_FALSE;
rconf->rule_extensions = NULL;
rconf->orig_uri = NULL;
ap_set_module_config(r->request_config, &jk_module, rconf);
}
if (!r->proxyreq) {
conf =
(jk_server_conf_t *) ap_get_module_config(r->server->
module_config,
&jk_module);
if (conf) {
rconf->request_id = get_env_string(r, NULL,
conf->request_id_indicator, 1);
if (rconf->request_id == NULL) {
rconf->request_id = get_env_string(r, NULL, JK_ENV_REQUEST_ID, 1);
}
}
}
if (!r->proxyreq && !apr_table_get(r->notes, JK_NOTE_WORKER_NAME)) {
if (conf) {
char *clean_uri;
int rc;
const char *worker;
jk_log_context_t log_ctx;
jk_log_context_t *l = &log_ctx;
l->logger = conf->log;
l->id = rconf->request_id;
JK_TRACE_ENTER(l);
if ((r->handler != NULL) && (!strcmp(r->handler, JK_HANDLER))) {
/* Somebody already set the handler, probably manual config
* or "native" configuration, no need for extra overhead
*/
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"Manually mapped, no need to call uri_to_worker");
JK_TRACE_EXIT(l);
return DECLINED;
}
if (apr_table_get(r->subprocess_env, "no-jk")) {
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"Into map_to_storage no-jk env var detected for uri=%s, declined",
r->uri);
JK_TRACE_EXIT(l);
return DECLINED;
}
// Not a URI based request - e.g. file based SSI include
if (strlen(r->uri) == 0) {
jk_log(l, JK_LOG_DEBUG,
"File based (sub-)request for file=%s. No URI to match.",
r->filename);
JK_TRACE_EXIT(l);
return DECLINED;
}
clean_uri = apr_pstrdup(r->pool, r->uri);
rc = jk_servlet_normalize(clean_uri, l);
if (rc != 0) {
JK_TRACE_EXIT(l);
return HTTP_BAD_REQUEST;
}
if (!conf->uw_map) {
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"missing uri map for %s:%s",
conf->s->server_hostname ? conf->s->server_hostname : "_default_",
r->uri);
JK_TRACE_EXIT(l);
return DECLINED;
}
else {
rule_extension_t *e;
worker = map_uri_to_worker_ext(conf->uw_map, clean_uri,
NULL, &e, NULL, l);
if (worker) {
rconf->rule_extensions = e;
rconf->orig_uri = r->uri;
r->uri = clean_uri;
}
}
if (worker) {
r->handler = apr_pstrdup(r->pool, JK_HANDLER);
apr_table_setn(r->notes, JK_NOTE_WORKER_NAME, worker);
/* This could be a sub-request, possibly from mod_dir */
if (r->main)
apr_table_setn(r->main->notes, JK_NOTE_WORKER_NAME, worker);
}
else {
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"no match for %s found",
r->uri);
if (conf->strip_session == JK_TRUE && conf->strip_session_name) {
if (r->uri) {
jk_strip_session_id(r->uri, conf->strip_session_name, l);
}
if (r->filename) {
jk_strip_session_id(r->filename, conf->strip_session_name, l);
}
JK_TRACE_EXIT(l);
return DECLINED;
}
}
JK_TRACE_EXIT(l);
}
}
if (apr_table_get(r->notes, JK_NOTE_WORKER_NAME)) {
/* First find just the name of the file, no directory */
r->filename = (char *)apr_filepath_name_get(r->uri);
/* Only if sub-request for a directory, most likely from mod_dir */
if (r->main && r->main->filename &&
(!apr_filepath_name_get(r->main->filename) ||
!strlen(apr_filepath_name_get(r->main->filename)))) {
/* The filename from the main request will be set to what should
* be picked up, aliases included. Tomcat will need to know about
* those aliases or things won't work for them. Normal files should
* be fine. */
/* Need absolute path to stat */
if (apr_filepath_merge(&r->filename,
r->main->filename, r->filename,
APR_FILEPATH_SECUREROOT |
APR_FILEPATH_TRUENAME, r->pool)
!= APR_SUCCESS) {
return DECLINED; /* We should never get here, very bad */
}
/* Stat the file so that mod_dir knows it's there */
apr_stat(&r->finfo, r->filename, APR_FINFO_TYPE, r->pool);
}
return OK;
}
return DECLINED;
}