From 67ad8aab15897202eeb08cabcccaa8b0ed219ac7 Mon Sep 17 00:00:00 2001 From: Atsushi Konno Date: Thu, 10 Mar 2011 18:48:26 +0900 Subject: [PATCH] * Fixed Bug. - Logic failure in chxj_apply_convrule * Changed internal specification. - use request_config for spec cache. --- include/mod_chxj.h | 1 + src/chxj_apply_convrule.c | 5 ++++- src/chxj_specified_device.c | 5 +++-- src/mod_chxj.c | 6 ++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/mod_chxj.h b/include/mod_chxj.h index 74e300e8..381ee3c8 100755 --- a/include/mod_chxj.h +++ b/include/mod_chxj.h @@ -380,6 +380,7 @@ struct mod_chxj_config { }; struct mod_chxj_req_config_t { + char *user_agent; device_table *spec; }; diff --git a/src/chxj_apply_convrule.c b/src/chxj_apply_convrule.c index 5028fe8e..5c9f2f32 100644 --- a/src/chxj_apply_convrule.c +++ b/src/chxj_apply_convrule.c @@ -26,11 +26,14 @@ chxj_apply_convrule(request_rec *r, apr_array_header_t *convrules) chxjconvrule_entry *pp; int ii; + + if (r->main) + return NULL; + entries = (chxjconvrule_entry *)convrules->elts; for (ii = 0; ii < convrules->nelts; ii++) { pp = &entries[ii]; - if (r->main) continue; /* Match */ if (s_apply_rule(r, pp)) diff --git a/src/chxj_specified_device.c b/src/chxj_specified_device.c index 1199f381..61cd6824 100644 --- a/src/chxj_specified_device.c +++ b/src/chxj_specified_device.c @@ -104,15 +104,16 @@ chxj_specified_device(request_rec *r, const char *user_agent) DBG(r, "REQ[%X] start %s()", TO_ADDR(r),__func__); request_conf = (mod_chxj_req_config *)chxj_get_module_config(r->request_config, &chxj_module); - if (request_conf && request_conf->spec) { + if (request_conf && request_conf->spec && request_conf->user_agent && strcmp(request_conf->user_agent, user_agent) == 0) { DBG(r, "REQ[%x] Use spec cache.", TO_ADDR(r)); DBG(r, "REQ[%x] end %s() (Exist spec cache)", TO_ADDR(r), __func__); return request_conf->spec; } - + request_conf->user_agent = user_agent; conf = chxj_get_module_config(r->per_dir_config, &chxj_module); if(! user_agent){ + request_conf->spec = dt; DBG(r, "REQ[%X] end %s() %d", TO_ADDR(r), __func__,conf->detect_device_type); return dt; } diff --git a/src/mod_chxj.c b/src/mod_chxj.c index 89cfee4a..43535345 100644 --- a/src/mod_chxj.c +++ b/src/mod_chxj.c @@ -193,11 +193,17 @@ chxj_headers_fixup(request_rec *r) if (!request_conf) { request_conf = apr_palloc(r->pool, sizeof(mod_chxj_req_config)); request_conf->spec = NULL; + request_conf->user_agent = NULL; chxj_set_module_config(r->request_config, &chxj_module, request_conf); } dconf = chxj_get_module_config(r->per_dir_config, &chxj_module); user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT); + + /* + * check and get mobile type. + * and request_conf->user_agent , request_conf->spec is set. + */ spec = chxj_specified_device(r, user_agent); contentType = (char *)apr_table_get(r->headers_in, "Content-Type"); -- 2.11.0