Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 56083 invoked by uid 500); 2 Jun 2000 12:31:57 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 56072 invoked from network); 2 Jun 2000 12:31:56 -0000 Date: Fri, 2 Jun 2000 08:31:50 -0400 Message-Id: <200006021231.IAA08074@k5.localdomain> X-Authentication-Warning: k5.localdomain: trawick set sender to trawickj@bellsouth.net using -f From: Jeff Trawick To: new-httpd@apache.org Subject: [PATCH] cleaning up calls to ap_checkconv() Reply-to: trawickj@bellsouth.net X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N This is as per Greg Ames's suggestion a week ago. I post it here first because I find the inclusion of such logic in ap_send_http_header() a bit ugly (but not as ugly as any alternatives I know of, all of which leave one module or another broken!). The recent change for APACHE_XLATE to ensure that the correct translation handle (if any) is used for error strings made this simple change possible. There was a mention in recent filtering discussions of the possibility of having Apache core (instead of handlers) call ap_send_http_header(). If so (why do I think this is extremely unlikely?) we should then move the call to ap_checkconv() from ap_send_http_header() to wherever in Apache core ap_send_http_header() is called. In addition to what you see in this patch, imagine that I have deleted calls to ap_checkconv() from mod_mmap_static and any other handlers inside or outside of apache CVS that can provide non-text content. Such handlers are broken today and will need calls to ap_checkconv() added if this isn't committed. Index: src/main/http_core.c =================================================================== RCS file: /cvs/apache/apache-2.0/src/main/http_core.c,v retrieving revision 1.62 diff -u -r1.62 http_core.c --- http_core.c 2000/05/27 22:40:27 1.62 +++ http_core.c 2000/06/01 18:38:29 @@ -2413,14 +2413,17 @@ } #ifdef CHARSET_EBCDIC - /* By default, we convert all content. ap_checkconv() can decide - * that conversion shouldn't be performed. Also, if the content type - * contains the "magic" prefix for serving raw ascii - * (text/x-ascii-{plain,html,...}), the type is corrected to the real - * text/{plain,html,...} type which goes into the headers. - */ - ap_checkconv(r); -#endif + 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) Index: src/main/http_protocol.c =================================================================== RCS file: /cvs/apache/apache-2.0/src/main/http_protocol.c,v retrieving revision 1.73 diff -u -r1.73 http_protocol.c --- http_protocol.c 2000/05/30 14:20:46 1.73 +++ http_protocol.c 2000/06/01 18:38:31 @@ -1630,6 +1630,20 @@ return; } +#ifdef CHARSET_EBCDIC + /* By default, we convert all content. ap_checkconv() can decide + * that conversion shouldn't be performed. Also, if the content type + * contains the "magic" prefix for serving raw ascii + * (text/x-ascii-{plain,html,...}), the type is corrected to the real + * text/{plain,html,...} type which goes into the headers. + * This may not seem like the best place to put this call, but doing + * it here avoids having to call it in every handler (which is + * particularly hard to do with handlers in modules which aren't + * part of the Apache httpd distribution). + */ + ap_checkconv(r); +#endif + /* * Now that we are ready to send a response, we need to combine the two * header field tables into a single table. If we don't do this, our Index: src/modules/standard/mod_cgi.c =================================================================== RCS file: /cvs/apache/apache-2.0/src/modules/standard/mod_cgi.c,v retrieving revision 1.43 diff -u -r1.43 mod_cgi.c --- mod_cgi.c 2000/05/28 11:48:24 1.43 +++ mod_cgi.c 2000/06/01 18:38:32 @@ -599,11 +599,6 @@ return log_script(r, conf, ret, dbuf, sbuf, script_in, script_err); } -#ifdef CHARSET_EBCDIC - /* Now check the Content-Type to decide if conversion is needed */ - ap_checkconv(r); -#endif /*CHARSET_EBCDIC*/ - location = ap_table_get(r->headers_out, "Location"); if (location && location[0] == '/' && r->status == 200) { Index: src/modules/standard/mod_cgid.c =================================================================== RCS file: /cvs/apache/apache-2.0/src/modules/standard/mod_cgid.c,v retrieving revision 1.12 diff -u -r1.12 mod_cgid.c --- mod_cgid.c 2000/05/27 22:40:36 1.12 +++ mod_cgid.c 2000/06/01 18:38:34 @@ -938,11 +938,6 @@ return log_script(r, conf, ret, dbuf, sbuf, script, NULL); } -#ifdef CHARSET_EBCDIC - /* Now check the Content-Type to decide if conversion is needed */ - ap_checkconv(r); -#endif /*CHARSET_EBCDIC*/ - location = ap_table_get(r->headers_out, "Location"); if (location && location[0] == '/' && r->status == 200) { -- Jeff Trawick | trawick@ibm.net | PGP public key at web site: http://www.geocities.com/SiliconValley/Park/9289/ Born in Roswell... married an alien...