From f48411ecfa431732774d71074728ba6acbd21b94 Mon Sep 17 00:00:00 2001 From: konn Date: Mon, 4 Feb 2008 04:57:46 +0000 Subject: [PATCH] * Fixed Bug - The image conversion is not operated at the access by PC. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/RELEASE_0_8_0@1818 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- ChangeLog | 7 ++++++ configure.ac | 2 +- debian/changelog | 7 ++++++ src/chxj_img_conv_format.c | 38 +++++++++++++++++++++++++++++++ src/mod_chxj.c | 56 ++++++++++++++++++++++++++++------------------ 5 files changed, 87 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 590fed2d..8187a9a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +libapache2-mod-chxj (0.8.3-1) unstable; urgency=high + + * Fixed Bug + - The image conversion is not operated at the access by PC. + + -- Atsushi Konno Mon, 4 Feb 2008 12:53:21 +0900 + libapache2-mod-chxj (0.8.2-1) unstable; urgency=low * Fixed Bug to which compile error occurs when A is specified. diff --git a/configure.ac b/configure.ac index 689215d5..e67662a7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([mod_chxj],[0.8.2-1]) +AC_INIT([mod_chxj],[0.8.3-1]) AC_PREREQ(2.59) AC_CONFIG_SRCDIR([src/mod_chxj.c]) AC_CANONICAL_TARGET diff --git a/debian/changelog b/debian/changelog index 0ef1a7c9..bf6a6778 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libapache2-mod-chxj (0.8.3-1) unstable; urgency=high + + * Fixed Bug + - The image conversion is not operated at the access by PC. + + -- Atsushi Konno Mon, 4 Feb 2008 12:53:21 +0900 + libapache2-mod-chxj (0.8.2-1) unstable; urgency=low * Fixed Bug to which compile error occurs when A is specified. diff --git a/src/chxj_img_conv_format.c b/src/chxj_img_conv_format.c index dd6a8e80..0adff13c 100644 --- a/src/chxj_img_conv_format.c +++ b/src/chxj_img_conv_format.c @@ -177,6 +177,9 @@ static apr_status_t s_send_cache_file( device_table* spec, request_rec* r, const char* tmpfile); +static apr_status_t s_send_original_file(request_rec* r, + const char* originalfile); + static apr_status_t s_header_only_cache_file(device_table* spec, query_string_param_t* query_string, request_rec* r, @@ -371,6 +374,13 @@ s_img_conv_format_from_file( apr_finfo_t cache_st; char* tmpfile; + if (spec->html_spec_type == CHXJ_SPEC_UNKNOWN) { + /* + * If ``ua'' parameter is specified, it must be CHXJ_SPEC_HTML. + */ + return s_send_original_file(r, r->filename); + } + /*--------------------------------------------------------------------------*/ /* Create Workfile Name */ /*--------------------------------------------------------------------------*/ @@ -1453,6 +1463,34 @@ s_send_cache_file(device_table* spec, query_string_param_t* query_string, reques return OK; } + +static apr_status_t +s_send_original_file(request_rec* r, const char* originalfile) +{ + apr_status_t rv; + apr_finfo_t st; + apr_file_t* fout; + apr_size_t sendbyte = 0; + + rv = apr_stat(&st, originalfile, APR_FINFO_MIN, r->pool); + if (rv != APR_SUCCESS) + return HTTP_NOT_FOUND; + + rv = apr_file_open(&fout, originalfile, + APR_READ | APR_BINARY, APR_OS_DEFAULT, r->pool); + if (rv != APR_SUCCESS) { + DBG1(r, "originalfile open failed[%s]", originalfile); + return HTTP_NOT_FOUND; + } + + ap_send_fd(fout, r, 0, st.size, &sendbyte); + apr_file_close(fout); + ap_rflush(r); + DBG1(r, "send file data[%d]byte", (int)sendbyte); + + return OK; +} + static apr_status_t s_header_only_cache_file(device_table* spec, query_string_param_t* query_string, request_rec* r, const char* tmpfile) { diff --git a/src/mod_chxj.c b/src/mod_chxj.c index f9241bc5..b25b96d6 100644 --- a/src/mod_chxj.c +++ b/src/mod_chxj.c @@ -185,14 +185,14 @@ chxj_headers_fixup(request_rec *r) * @param len [i/o] It is length of former HTML character string. */ static char* -chxj_exchange(request_rec *r, const char** src, apr_size_t* len) +chxj_exchange(request_rec *r, const char** src, apr_size_t* len, device_table *spec, const char *ua) { - char* user_agent; - char* dst; - char* tmp; - cookie_t* cookie; - mod_chxj_config* dconf; - chxjconvrule_entry* entryp; + char *user_agent; + char *dst; + char *tmp; + cookie_t *cookie; + mod_chxj_config *dconf; + chxjconvrule_entry *entryp; dst = apr_pstrcat(r->pool, (char*)*src, NULL); @@ -224,7 +224,10 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len) return (char*)*src; } - device_table* spec = chxj_specified_device(r, user_agent); + if (ua && user_agent && strcasecmp(user_agent, ua) != 0) { + /* again */ + spec = chxj_specified_device(r, user_agent); + } /* * save cookie. @@ -610,17 +613,18 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) apr_bucket* b; const char* data; char* contentLength; + char* user_agent; apr_size_t len; mod_chxj_ctx* ctx; cookie_t* cookie; char* location_header; mod_chxj_config* dconf; - chxjconvrule_entry* entryp; + chxjconvrule_entry *entryp; + device_table *spec; DBG(f->r, "start of chxj_output_filter()"); - r = f->r; rv = APR_SUCCESS; @@ -631,8 +635,10 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) f->r->chunked = 1; } - dconf = ap_get_module_config(r->per_dir_config, &chxj_module); - entryp = chxj_apply_convrule(r, dconf->convrules); + dconf = ap_get_module_config(r->per_dir_config, &chxj_module); + entryp = chxj_apply_convrule(r, dconf->convrules); + user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT); + spec = chxj_specified_device(r, user_agent); for (b = APR_BRIGADE_FIRST(bb); @@ -651,9 +657,10 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) DBG1(r, "content_type=[%s]", r->content_type); - if (r->content_type - && *(char*)r->content_type == 't' - && strncmp(r->content_type, "text/html", 9) == 0) { + if (spec->html_spec_type != CHXJ_SPEC_UNKNOWN + && r->content_type + && *(char*)r->content_type == 't' + && strncmp(r->content_type, "text/html", 9) == 0) { if (ctx->len) { char* tmp; @@ -669,7 +676,9 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) ctx->buffer = chxj_exchange(r, (const char**)&tmp, - (apr_size_t*)&ctx->len); + (apr_size_t*)&ctx->len, + spec, + user_agent); #if 0 DBG2(r, "output data=[%.*s]", ctx->len,ctx->buffer); @@ -680,13 +689,15 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) ctx->len += 1; ctx->buffer = chxj_exchange(r, (const char**)&ctx->buffer, - (apr_size_t*)&ctx->len); + (apr_size_t*)&ctx->len, + spec, + user_agent); } } if (r->content_type - && *(char*)r->content_type == 't' - && strncmp(r->content_type, "text/xml", 8) == 0) { + && *(char*)r->content_type == 't' + && strncmp(r->content_type, "text/xml", 8) == 0) { DBG(r, "text/XML"); Doc doc; @@ -733,9 +744,10 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) } } - if (r->content_type - && *(char*)r->content_type == 'i' - && strncmp(r->content_type, "image/", 6) == 0) { + if (spec->html_spec_type != CHXJ_SPEC_UNKNOWN + && r->content_type + && *(char*)r->content_type == 'i' + && strncmp(r->content_type, "image/", 6) == 0) { if (ctx->len) { char* tmp; -- 2.11.0