フィルタの勉強: Content-Length

Content-Lengthを設定し直さないと…と思ってhttpd-2.2.8/modules/filters以下のソースにgrepをかけてみる。


mod_charset_lite.c:845: * Content-Length since it is unlikely to remain the same.
mod_charset_lite.c:847: apr_table_unset(f->r->headers_out, "Content-Length");
mod_charset_lite.c:1008: && apr_table_get(f->r->headers_in, "Content-Length")) {
mod_charset_lite.c:1009: /* A Content-Length header is present, but it won't be valid after
mod_charset_lite.c:1013: * Content-Length can't be unset here because that would break
mod_deflate.c:587: apr_table_unset(r->headers_out, "Content-Length");
mod_deflate.c:797: apr_table_unset(r->headers_in, "Content-Length");
mod_deflate.c:1080: apr_table_unset(r->headers_out, "Content-Length");
mod_ext_filter.c:623: apr_table_unset(f->r->headers_out, "Content-Length");
mod_filter.c:310: apr_table_unset(r->headers_out, "Content-Length");
mod_include.c:3617: apr_table_unset(f->r->headers_out, "Content-Length");
mod_substitute.c:301: apr_table_unset(f->r->headers_out, "Content-Length");
…どうも、apr_table_set()しているところがないような。
コメントを拾ってみる。

mod_charset_lite.c

/* We're not converting between two single-byte charsets, so unset
 * Content-Length since it is unlikely to remain the same.
 */
apr_table_unset(f->r->headers_out, "Content-Length");

mod_deflate.c

/* these are unlikely to be set anyway, but ... */
apr_table_unset(r->headers_out, "Content-Length");
apr_table_unset(r->headers_out, "Content-MD5");
deflate_check_etag(r, "gunzip");

mod_ext_filter.c

/* nasty, but needed to avoid confusing the browser
 */
apr_table_unset(f->r->headers_out, "Content-Length");

mod_filter.c

/* things that are invalidated if the filter transforms content */
if (proto_flags & AP_FILTER_PROTO_CHANGE) {
    apr_table_unset(r->headers_out, "Content-MD5");
    apr_table_unset(r->headers_out, "ETag");
    if (proto_flags & AP_FILTER_PROTO_CHANGE_LENGTH) {
        apr_table_unset(r->headers_out, "Content-Length");
    }
}

mod_include.c

/* Always unset the content-length.  There is no way to know if
 * the content will be modified at some point by send_parsed_content.
 * It is very possible for us to not find any content in the first
 * 9k of the file, but still have to modify the content of the file.
 * If we are going to pass the file through send_parsed_content, then
 * the content-length should just be unset.
 */
apr_table_unset(f->r->headers_out, "Content-Length");

…ん〜、とりあえずContent-Lengthはapr_table_unset()しておけばいいかな。
nastyだけどしょうがない…ということにしておこう。