From 43c2b45f388432ddce2a790ebca09d57fd37d71d Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Sat, 3 Jun 2000 22:41:01 +0000 Subject: [PATCH] EBCDIC: Rearrange calls to ap_checkconv() so that most handlers won't need to call it. Submitted by: Greg Ames, Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85397 13f79535-47bb-0310-9956-ffa450edef68 --- modules/generators/mod_cgi.c | 5 ----- modules/generators/mod_cgid.c | 5 ----- modules/http/http_core.c | 19 +++++++++++-------- modules/http/http_protocol.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index c969a40c69..6dd6a52cf9 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -599,11 +599,6 @@ static int cgi_handler(request_rec *r) 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) { diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index e8f932745b..e45c89a5b2 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -938,11 +938,6 @@ static int cgid_handler(request_rec *r) 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) { diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 6de6ff3c97..4a948e296a 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -2416,14 +2416,17 @@ static int default_handler(request_rec *r) } #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) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 14c638d7a1..4eaa06f6c6 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -1641,6 +1641,20 @@ API_EXPORT(void) ap_send_http_header(request_rec *r) 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 -- 2.40.0