.color = 15680000,
.emoji_type = NULL,
};
-static __thread device_table *v_spec = NULL;
static device_table * s_get_device_data(request_rec *r, const char *device_id, device_table_list *dtl);
/**
device_table *returnType = &UNKNOWN_DEVICE;
device_table_list *dtl;
mod_chxj_config *conf;
+ mod_chxj_req_config *request_conf;
char *device_id;
- char *spec_check = NULL;
DBG(r,"REQ[%x] start %s()", TO_ADDR(r), __func__ );
return returnType;
}
-
-
- spec_check = (char *)apr_table_get(r->headers_in, "X-Chxj-Spec-Check");
- if (spec_check && STRCASEEQ('d','D',"done",spec_check)) {
+ /*
+ * Get per request config.
+ */
+ request_conf = (mod_chxj_req_config *)chxj_get_module_config(r->request_config, &chxj_module);
+ if (request_conf && request_conf->spec) {
DBG(r,"REQ[%x] Use spec cache.", (unsigned int)(apr_size_t)r);
- returnType = v_spec;
- DBG(r,"REQ[%x] end %s() (Spec-Check-Done)", TO_ADDR(r),__func__);
+ returnType = request_conf->spec;
+ DBG(r,"REQ[%x] end %s() (Exist requestConf)", TO_ADDR(r),__func__);
return returnType;
}
conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
if (! conf->devices) {
ERR(r,"REQ[%X] device_data.xml load failure", TO_ADDR(r));
- DBG(r,"REQ[%x] end %s() (Spec-Check-Done)", TO_ADDR(r),__func__);
+ DBG(r,"REQ[%x] end %s()", TO_ADDR(r),__func__);
return returnType;
}
/* DBG(r, "REQ[%X] pattern is [%s]", TO_ADDR(r), dtl->pattern); */
if (! dtl->regexp) {
ERR(r,"REQ[%X] compile failed.", TO_ADDR(r));
- DBG(r,"REQ[%x] end %s() (Spec-Check-Done)", TO_ADDR(r),__func__);
+ DBG(r,"REQ[%x] end %s()", TO_ADDR(r),__func__);
return returnType;
}
returnType = &UNKNOWN_DEVICE;
}
}
- v_spec = returnType;
- apr_table_setn(r->headers_in, "X-Chxj-Spec-Check", "done");
+ request_conf->spec = returnType;
DBG(r,"REQ[%X] end %s() (Found User-Agent Type)", TO_ADDR(r),__func__);
return returnType;
}
}
- v_spec = &UNKNOWN_DEVICE;
- apr_table_setn(r->headers_in, "X-Chxj-Spec-Check", "done");
+ request_conf->spec = &UNKNOWN_DEVICE;
DBG(r,"REQ[%X] end %s() (Not Found User-Agent Type) [%s]",TO_ADDR(r), __func__,user_agent);
return &UNKNOWN_DEVICE;
chxj_specified_cleanup(request_rec *r)
{
DBG(r,"REQ[%X] start %s()",TO_ADDR(r), __func__);
- v_spec = NULL;
DBG(r,"REQ[%X] end %s()",TO_ADDR(r), __func__);
}
chxj_headers_fixup(request_rec *r)
{
mod_chxj_config* dconf;
+ mod_chxj_req_config* request_conf;
chxjconvrule_entry* entryp;
char* user_agent;
device_table* spec;
dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT);
+
+ /*
+ * make space for the per request config
+ */
+ request_conf = (mod_chxj_req_config *)chxj_get_module_config(r->request_config, &chxj_module);
+ if (! request_conf) {
+ request_conf = apr_pcalloc(r->pool, sizeof(mod_chxj_req_config));
+ request_conf->spec = NULL;
+ chxj_set_module_config(r->request_config, &chxj_module, request_conf);
+ }
+
+ /*
+ * check and get mobile type.
+ */
spec = chxj_specified_device(r, user_agent);
contentType = (char *)apr_table_get(r->headers_in, "Content-Type");