X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fchxj_img_conv_format.c;h=8d6da511493d0d3836822e12321851f10281b5c4;hb=651a102146748117ea4d9b271e8eaf65299fa5c8;hp=77d2fc433f93c4169cc7c73f73778c5e3030b3a4;hpb=a8e953da7b20fe91b4069428f79d822f851904e6;p=modchxj%2Fmod_chxj.git diff --git a/src/chxj_img_conv_format.c b/src/chxj_img_conv_format.c index 77d2fc43..8d6da511 100644 --- a/src/chxj_img_conv_format.c +++ b/src/chxj_img_conv_format.c @@ -1837,28 +1837,68 @@ s_send_cache_file( } char *nowFormat = MagickGetImageFormat(magick_wand); DestroyMagickWand(magick_wand); + char *fname = apr_pstrdup(r->pool, r->filename); + char *ext = strrchr(fname, '.'); if (nowFormat) { if (STRCASEEQ('j','J',"jpeg",nowFormat) || STRCASEEQ('j','J',"jpg",nowFormat)) { DBG(r,"REQ[%X] detect cache file => jpg.",TO_ADDR(r)); ap_set_content_type(r, "image/jpeg"); + + if (!ext) { + fname = apr_pstrcat(r->pool, fname, ".jpg"); + } + else if (ext && strcasecmp(".jpeg", ext) != 0 && strcasecmp(".jpg", ext) != 0) { + *ext = 0; + fname = apr_pstrcat(r->pool, fname, ".jpg"); + } } else if (STRCASEEQ('p','P',"png", nowFormat)) { DBG(r,"REQ[%X] detect cache file => png.",TO_ADDR(r)); ap_set_content_type(r, "image/png"); + + if (!ext) { + fname = apr_pstrcat(r->pool, fname, ".png"); + } + else if (ext && strcasecmp(".png", ext) != 0) { + *ext = 0; + fname = apr_pstrcat(r->pool, fname, ".png"); + } + } else if (STRCASEEQ('g','G',"gif", nowFormat)) { DBG(r,"REQ[%X] detect cache file => gif.",TO_ADDR(r)); ap_set_content_type(r, "image/gif"); + + if (!ext) { + fname = apr_pstrcat(r->pool, fname, ".gif"); + } + else if (ext && strcasecmp(".gif", ext) != 0) { + *ext = 0; + fname = apr_pstrcat(r->pool, fname, ".gif"); + } } else if (STRCASEEQ('b','B',"bmp", nowFormat)) { DBG(r,"REQ[%X] detect cache file => bmp.",TO_ADDR(r)); ap_set_content_type(r, "image/bmp"); + + if (!ext) { + fname = apr_pstrcat(r->pool, fname, ".bmp"); + } + else if (ext && strcasecmp(".bmp", ext) != 0) { + *ext = 0; + fname = apr_pstrcat(r->pool, fname, ".bmp"); + } } else { ERR(r,"REQ[%X] detect unknown file",TO_ADDR(r)); return HTTP_NOT_FOUND; } } + if (query_string->mode == IMG_CONV_MODE_WALLPAPER && (IS_IPHONE(spec)||IS_ANDROID(spec))) { + ap_set_content_type(r, "application/octet-stream"); + apr_table_setn(r->headers_out, "Content-Disposition", apr_psprintf(r->pool, "attachment; filename=%s", fname)); + DBG(r,"REQ[%X] detect cache file => iphone/android",TO_ADDR(r)); + } if (conf->image_copyright) { DBG(r,"REQ[%X] Add COPYRIGHT Header for SoftBank [%s]", TO_ADDR(r), conf->image_copyright); if (spec->html_spec_type == CHXJ_SPEC_Jhtml || spec->html_spec_type == CHXJ_SPEC_Jxhtml) {