From: Justin Erenkrantz Date: Tue, 28 Sep 2004 16:26:48 +0000 (+0000) Subject: mod_disk_cache: Do not store aborted content. X-Git-Tag: 2.1.1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c31031d142e67782098e155382a03ebe4717f2d;p=thirdparty%2Fapache%2Fhttpd.git mod_disk_cache: Do not store aborted content. PR: 21492 Submitted by: R�diger Pl�m Reviewed by: Justin Erenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105317 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c67582a89ab..bd4923e479a 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) mod_disk_cache: Do not store aborted content. PR 21492. + [Rüdiger Plüm ] + *) mod_disk_cache: Correctly store cached content type. PR 30278. [Rüdiger Plüm ] diff --git a/modules/experimental/mod_disk_cache.c b/modules/experimental/mod_disk_cache.c index 0c9ccd3540b..125bec9c406 100644 --- a/modules/experimental/mod_disk_cache.c +++ b/modules/experimental/mod_disk_cache.c @@ -701,6 +701,22 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, */ if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) { if (h->cache_obj->info.len <= 0) { + /* If the target value of the content length is unknown + * (h->cache_obj->info.len <= 0), check if connection has been + * aborted by client to avoid caching incomplete request bodies. + * + * This can happen with large responses from slow backends like + * Tomcat via mod_jk. + */ + if (r->connection->aborted) { + ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, + "disk_cache: Discarding body for URL %s " + "because connection has been aborted.", + h->cache_obj->key); + /* Remove the intermediate cache file and return non-APR_SUCCESS */ + file_cache_errorcleanup(dobj, r); + return APR_EGENERAL; + } /* XXX Fixme: file_size isn't constrained by size_t. */ h->cache_obj->info.len = dobj->file_size; }