OSDN Git Service

* Fixed Bug.
authorAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 09:48:26 +0000 (18:48 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 09:48:26 +0000 (18:48 +0900)
    - Logic failure in chxj_apply_convrule
  * Changed internal specification.
    - use request_config for spec cache.

include/mod_chxj.h
src/chxj_apply_convrule.c
src/chxj_specified_device.c
src/mod_chxj.c

index 74e300e..381ee3c 100755 (executable)
@@ -380,6 +380,7 @@ struct mod_chxj_config {
 };
 
 struct mod_chxj_req_config_t {
+  char         *user_agent;
   device_table *spec;
 };
 
index 5028fe8..5c9f2f3 100644 (file)
@@ -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)) 
index 1199f38..61cd682 100644 (file)
@@ -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;
   }
index 89cfee4..4353534 100644 (file)
@@ -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");