extern char * chxj_os_escape_path(apr_pool_t *p, const char *path, int partial);
extern void chxj_set_content_type(request_rec *r, const char *ct);
extern void * chxj_get_module_config(const ap_conf_vector_t *cv, const module *m);
+extern void chxj_set_module_config(const ap_conf_vector_t *cv, const module *m, void *val);
extern char *chxj_ap_escape_html(apr_pool_t *p, const char *s);
extern ap_regex_t *chxj_ap_pregcomp(apr_pool_t *p, const char *pattern, int cflags);
extern void chxj_ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
.output_encoding = "Shift_JIS",
};
/* spec cache */
-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);
static device_table *s_specified_device_from_xml(request_rec *r, mod_chxj_config * conf, const char *user_agent);
static device_table *s_specified_device_from_tsv(request_rec *r,device_table *spec,const char *user_agent);
device_table *dt = &UNKNOWN_DEVICE;
mod_chxj_config *conf;
char *spec_check = NULL;
+ mod_chxj_req_config *request_conf;
DBG(r, "REQ[%X] start %s()", TO_ADDR(r),__func__);
- /*
- * if I have spec cache, I will use it.
- */
- spec_check = (char *)apr_table_get(r->headers_in, "X-Chxj-Spec-Check");
- if (spec_check && STRCASEEQ('d','D',"done",spec_check)) {
- dt = v_spec;
+ 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.", TO_ADDR(r));
- DBG(r, "REQ[%x] end %s() (Spec-Check-Done)", (unsigned int)(apr_size_t)r, __func__);
- return dt;
+ DBG(r, "REQ[%x] end %s() (Exist spec cache)", (unsigned int)(apr_size_t)r, __func__);
+ return request_conf->spec;
}
+
conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
if(! user_agent){
DBG(r, "REQ[%X] end %s() %d", TO_ADDR(r), __func__,conf->detect_device_type);
s_specified_device_from_tsv(r,dt,user_agent);
}
/* save to spec cache */
- v_spec = dt;
- apr_table_setn(r->headers_in, "X-Chxj-Spec-Check", "done");
+ request_conf->spec = dt;
DBG(r, "REQ[%X] end %s() %d",TO_ADDR(r), __func__,conf->detect_device_type);
return dt;
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;
return DECLINED;
}
+ request_conf = (mod_chxj_req_config *)chxj_get_module_config(r->request_config, &chxj_module);
+ if (!request_conf) {
+ request_conf = apr_palloc(r->pool, sizeof(mod_chxj_req_config));
+ request_conf->spec = 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);