From: konn Date: Sun, 30 Mar 2008 13:08:30 +0000 (+0000) Subject: * Added Content-type ``application/xhtml+xml'' X-Git-Tag: v0.12.20~808 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5083bf6406595001046056e78838658f79da7427;p=modchxj%2Fmod_chxj.git * Added Content-type ``application/xhtml+xml'' git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/RELEASE_0_10_0@1952 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- diff --git a/src/chxj_specified_device.c b/src/chxj_specified_device.c index 73c2e67d..af407e8d 100644 --- a/src/chxj_specified_device.c +++ b/src/chxj_specified_device.c @@ -92,7 +92,7 @@ chxj_specified_device(request_rec* r, const char* user_agent) continue; } - DBG(r, "pattern is [%s]", dtl->pattern); + /* DBG(r, "pattern is [%s]", dtl->pattern); */ if (! dtl->regexp) { DBG(r,"compile failed."); return returnType; diff --git a/src/mod_chxj.c b/src/mod_chxj.c index 16f7975e..807d82aa 100644 --- a/src/mod_chxj.c +++ b/src/mod_chxj.c @@ -199,6 +199,7 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len, device_table *s mod_chxj_config *dconf; chxjconvrule_entry *entryp; + DBG(r,"start of chxj_exchange() input:[%.*s]", *len, *src); dst = apr_pstrcat(r->pool, (char*)*src, NULL); dconf = ap_get_module_config(r->per_dir_config, &chxj_module); @@ -219,13 +220,13 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len, device_table *s user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT); DBG(r,"User-Agent:[%s]", user_agent); - DBG(r, "start chxj_exchange()"); DBG(r,"content type is %s", r->content_type); - if (*(char*)r->content_type == 't' - && strncmp(r->content_type, "text/html", 9) != 0) { - DBG(r,"content type is %s", r->content_type); + if (! STRNCASEEQ('t','T', "text/html", r->content_type, sizeof("text/html")) + && ! STRNCASEEQ('a','A', "application/xhtml+xml", r->content_type, sizeof("application/xhtml+xml"))) { + DBG(r,"no convert. content type is %s", r->content_type); + DBG(r,"end of chxj_exchange()"); return (char*)*src; } @@ -287,7 +288,7 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len, device_table *s } dst[*len] = 0; - DBG(r, "end chxj_exchange()"); + DBG(r, "end of chxj_exchange()"); return dst; } @@ -642,6 +643,7 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) if (r->content_type) { if (! STRNCASEEQ('t','T',"text/html",r->content_type, sizeof("text/html")-1) && ! STRNCASEEQ('t','T',"text/xml", r->content_type, sizeof("text/xml")-1) + && ! STRNCASEEQ('a','A',"application/xhtml+xml", r->content_type, sizeof("application/xhtml+xml")-1) && ! (STRNCASEEQ('i','I',"image/", r->content_type, sizeof("image/") -1) && ( STRCASEEQ('j','J',"jpeg", &r->content_type[6]) /* JPEG */ || STRCASEEQ('j','J',"jp2", &r->content_type[6]) /* JPEG2000 */ @@ -675,6 +677,51 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { + if (apr_bucket_read(b, &data, &len, APR_BLOCK_READ) == APR_SUCCESS) { + DBG(r, "read data[%.*s]",(int)len, data); + + if (f->ctx == NULL) { + /*--------------------------------------------------------------------*/ + /* Start */ + /*--------------------------------------------------------------------*/ + DBG(r, "new context"); + ctx = (mod_chxj_ctx*)apr_palloc(r->pool, sizeof(mod_chxj_ctx)); + if (len > 0) { + ctx->buffer = apr_palloc(r->pool, len); + memcpy(ctx->buffer, data, len); + } + else { + ctx->buffer = apr_palloc(r->pool, 1); + ctx->buffer = '\0'; + } + ctx->len = len; + f->ctx = (void*)ctx; + ctx->entryp = entryp; + ctx->spec = spec; + } + else { + /*--------------------------------------------------------------------*/ + /* append data */ + /*--------------------------------------------------------------------*/ + char* tmp; + DBG(r, "append data start"); + ctx = (mod_chxj_ctx*)f->ctx; + + if (len > 0) { + tmp = apr_palloc(r->pool, ctx->len); + memcpy(tmp, ctx->buffer, ctx->len); + + ctx->buffer = apr_palloc(r->pool, ctx->len + len); + + memcpy(ctx->buffer, tmp, ctx->len); + memcpy(&ctx->buffer[ctx->len], data, len); + + ctx->len += len; + } + DBG(r, "append data end"); + } + } + if (APR_BUCKET_IS_EOS(b)) { DBG(r, "eos"); @@ -689,8 +736,8 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) if (spec->html_spec_type != CHXJ_SPEC_UNKNOWN && r->content_type - && *(char*)r->content_type == 't' - && strncmp(r->content_type, "text/html", 9) == 0) { + && (STRNCASEEQ('a','A',"application/xhtml+xml", r->content_type, sizeof("application/xhtml+xml")) + || STRNCASEEQ('t','T',"text/html", r->content_type, sizeof("text/html")))) { if (ctx->len) { char* tmp; @@ -871,51 +918,6 @@ chxj_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) return rv; } } - else - if (apr_bucket_read(b, &data, &len, APR_BLOCK_READ) == APR_SUCCESS) { - DBG(r, "read data[%.*s]",(int)len, data); - - if (f->ctx == NULL) { - /*--------------------------------------------------------------------*/ - /* Start */ - /*--------------------------------------------------------------------*/ - DBG(r, "new context"); - ctx = (mod_chxj_ctx*)apr_palloc(r->pool, sizeof(mod_chxj_ctx)); - if (len > 0) { - ctx->buffer = apr_palloc(r->pool, len); - memcpy(ctx->buffer, data, len); - } - else { - ctx->buffer = apr_palloc(r->pool, 1); - ctx->buffer = '\0'; - } - ctx->len = len; - f->ctx = (void*)ctx; - ctx->entryp = entryp; - ctx->spec = spec; - } - else { - /*--------------------------------------------------------------------*/ - /* append data */ - /*--------------------------------------------------------------------*/ - char* tmp; - DBG(r, "append data start"); - ctx = (mod_chxj_ctx*)f->ctx; - - if (len > 0) { - tmp = apr_palloc(r->pool, ctx->len); - memcpy(tmp, ctx->buffer, ctx->len); - - ctx->buffer = apr_palloc(r->pool, ctx->len + len); - - memcpy(ctx->buffer, tmp, ctx->len); - memcpy(&ctx->buffer[ctx->len], data, len); - - ctx->len += len; - } - DBG(r, "append data end"); - } - } } apr_brigade_destroy(bb);