OSDN Git Service

* Added feature.
authorAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 09:58:07 +0000 (18:58 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 09:58:07 +0000 (18:58 +0900)
    - remove output_filter if it is not necessary.
    - remove chxj_specified_cleanup.

include/mod_chxj.h
src/chxj_img_conv_format.c
src/mod_chxj.c

index 381ee3c..a5966b1 100755 (executable)
@@ -382,6 +382,7 @@ struct mod_chxj_config {
 struct mod_chxj_req_config_t {
   char         *user_agent;
   device_table *spec;
+  ap_filter_t  *f;
 };
 
 #define IS_COOKIE_STORE_DBM(X)      ((X) == COOKIE_STORE_TYPE_DBM)
@@ -536,6 +537,7 @@ extern char *chxj_node_convert_chxjif_only(
   const char   *src,
   apr_size_t   *len
 );
+extern void chxj_remove_filter(request_rec *r);
 
 #define IMAGE_CACHE_LIMIT_FMT_LEN  (20)
 
index c6ffaa9..63bd9e5 100644 (file)
@@ -320,6 +320,10 @@ chxj_img_conv_format_handler(request_rec *r)
   DBG(r,"REQ[%X] User-Agent=[%s]", TO_ADDR(r), user_agent);
 
 
+  /*-------------------------------------------------------------------------*/
+  /* Do not process output_filter                                            */
+  /*-------------------------------------------------------------------------*/
+  chxj_remove_filter(r);
   rtn = s_img_conv_format_from_file(r, conf, user_agent, qsp, spec);
   DBG(r,"REQ[%X] end %s()",TO_ADDR(r),__func__);
   return rtn;
index 4353534..5e6b7ad 100644 (file)
@@ -194,6 +194,7 @@ chxj_headers_fixup(request_rec *r)
     request_conf = apr_palloc(r->pool, sizeof(mod_chxj_req_config));
     request_conf->spec = NULL;
     request_conf->user_agent = NULL;
+    request_conf->f = NULL;
     chxj_set_module_config(r->request_config, &chxj_module, request_conf);
   }
   dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
@@ -1718,6 +1719,7 @@ chxj_insert_filter(request_rec *r)
   char                *user_agent;
   device_table        *spec;
   mod_chxj_config     *dconf;
+  mod_chxj_req_config *req_conf;
   chxjconvrule_entry  *entryp;
   mod_chxj_ctx        *ctx;
   apr_status_t        rv;
@@ -1726,6 +1728,7 @@ chxj_insert_filter(request_rec *r)
   DBG(r, "REQ[%X] start %s()", TO_ADDR(r),__func__);
 
   dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+  req_conf = chxj_get_module_config(r->request_config, &chxj_module);
 
   /* we get User-Agent from CHXJ_HTTP_USER_AGENT header if any */
   user_agent = (char *)apr_table_get(r->headers_in, CHXJ_HTTP_USER_AGENT);
@@ -1786,7 +1789,7 @@ chxj_insert_filter(request_rec *r)
 
 
   if (! apr_table_get(r->headers_in, "X-Chxj-Forward")) {
-    ap_add_output_filter("chxj_output_filter", ctx, r, r->connection);
+    req_conf->f = ap_add_output_filter("chxj_output_filter", ctx, r, r->connection);
     DBG(r, "REQ[%X] added Output Filter", TO_ADDR(r));
   }
 
@@ -1794,6 +1797,21 @@ chxj_insert_filter(request_rec *r)
 }
 
 
+void 
+chxj_remove_filter(request_rec *r)
+{
+  mod_chxj_req_config *req_conf;
+
+  DBG(r, "REQ[%X] start %s()", TO_ADDR(r),__func__);
+  req_conf = chxj_get_module_config(r->request_config, &chxj_module);
+  if (req_conf && req_conf->f) {
+    ap_remove_output_filter(req_conf->f);
+    DBG(r, "REQ[%X] REMOVE Output Filter", TO_ADDR(r));
+  }
+  DBG(r, "REQ[%X] end %s()", TO_ADDR(r),__func__);
+}
+
+
 /**
  * The hook is registered.
  *