From: Jeff Trawick Date: Wed, 4 Oct 2000 17:14:00 +0000 (+0000) Subject: Clean up md5 digest support in default_handler() a bit: X-Git-Tag: APACHE_2_0_ALPHA_7~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eed0345ff6990fbcfcfa308981d52641b9097e04;p=apache Clean up md5 digest support in default_handler() a bit: 1) don't compute md5 if we have a content filter; it is almost always wrong 2) add note about adding md5 filter in the future; this can be done 3) delete some APACHE_XLATE/CHARSET_EBCDIC baggage associated with md5 digest support; part of this deleted baggage is a segfault on subrequests referencing r->rrx (which is not allocated for subrequests) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86385 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_core.c b/modules/http/http_core.c index db141bf15e..fe97cab5f7 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -2839,6 +2839,15 @@ static int default_handler(request_rec *r) #ifdef USE_MMAP_FILES apr_mmap_t *mm = NULL; #endif + /* XXX if/when somebody writes a content-md5 filter we either need to + * remove this support or coordinate when to use the filter vs. + * when to use this code + * The current choice of when to compute the md5 here matches the 1.3 + * support fairly closely (unlike 1.3, we don't handle computing md5 + * when the charset is translated). + */ + int bld_content_md5 = + (d->content_md5 & 1) && r->output_filters->frec->ftype != AP_FTYPE_CONTENT; /* This handler has no use for a request body (yet), but we still * need to read and discard it if the client sent one. @@ -2886,22 +2895,10 @@ static int default_handler(request_rec *r) return errstatus; } -#ifdef CHARSET_EBCDIC - if (d->content_md5 & 1) { - /* The call to ap_checkconv() in ap_send_http_header() is - * sufficient for most paths. Sending the MD5 digest in a - * header is special in that any change to translation decided - * by ap_checkconv() must be done before building that header, - * and thus before calling ap_send_http_header(). - */ - ap_checkconv(r); - } -#endif /* CHARSET_EBCDIC */ - #ifdef USE_MMAP_FILES if ((r->finfo.size >= MMAP_THRESHOLD) && (r->finfo.size < MMAP_LIMIT) - && (!r->header_only || (d->content_md5 & 1))) { + && (!r->header_only || bld_content_md5)) { /* we need to protect ourselves in case we die while we've got the * file mmapped */ apr_status_t status; @@ -2918,18 +2915,15 @@ static int default_handler(request_rec *r) if (mm == NULL) { #endif + if (bld_content_md5) { #ifdef APACHE_XLATE - if (d->content_md5 & 1) { apr_table_setn(r->headers_out, "Content-MD5", - ap_md5digest(r->pool, fd, - r->rrx->to_net)); - } + ap_md5digest(r->pool, fd, NULL)); #else - if (d->content_md5 & 1) { apr_table_setn(r->headers_out, "Content-MD5", - ap_md5digest(r->pool, fd)); - } + ap_md5digest(r->pool, fd)); #endif /* APACHE_XLATE */ + } rangestatus = ap_set_byterange(r); @@ -2960,15 +2954,10 @@ static int default_handler(request_rec *r) unsigned char *addr; apr_mmap_offset((void**)&addr, mm ,0); - if (d->content_md5 & 1) { + if (bld_content_md5) { apr_md5_ctx_t context; apr_MD5Init(&context); -#ifdef APACHE_XLATE - if (r->rrx->to_net) { - apr_MD5SetXlate(&context, r->rrx->to_net); - } -#endif apr_MD5Update(&context, addr, (unsigned int)r->finfo.size); apr_table_setn(r->headers_out, "Content-MD5", ap_md5contextTo64(r->pool, &context));