Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 70821 invoked by uid 500); 4 Jun 2000 19:27:03 -0000 Mailing-List: contact apache-cvs-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 apache-cvs@apache.org Received: (qmail 70803 invoked by uid 500); 4 Jun 2000 19:27:02 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 4 Jun 2000 19:27:02 -0000 Message-ID: <20000604192702.70793.qmail@locus.apache.org> From: trawick@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/modules/experimental mod_charset_lite.c trawick 00/06/04 12:27:02 Modified: src/modules/experimental mod_charset_lite.c Log: mod_charset_lite: functional changes: setup input translation for PUT or POST other: bail out more quickly if our dir config says do nothing, tweak the debug trace, Revision Changes Path 1.3 +40 -16 apache-2.0/src/modules/experimental/mod_charset_lite.c Index: mod_charset_lite.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/experimental/mod_charset_lite.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_charset_lite.c 2000/05/30 14:31:04 1.2 +++ mod_charset_lite.c 2000/06/04 19:27:02 1.3 @@ -154,30 +154,21 @@ { charset_dir_t *dc = ap_get_module_config(r->per_dir_config, &charset_lite_module); ap_status_t rv; - ap_xlate_t *xlate; + ap_xlate_t *input_xlate, *output_xlate; const char *mime_type; int debug = dc->debug == DEBUG; - mime_type = r->content_type ? r->content_type : ap_default_type(r); - if (debug) { ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, - "Entering handler, URI: %s FILENAME: %s ARGS: %s PATH_INFO: %s " + "Entering handler, URI: %s FILENAME: %s METHOD: %d ARGS: %s PATH_INFO: %s " "MIMETYPE: %s FLAGS: %d SUBREQ: %s, REDIR: %s, PROXY: %s", - r->uri, r->filename, r->args, r->path_info, mime_type, + r->uri, r->filename, r->method_number, r->args, r->path_info, + r->content_type ? r->content_type : "(unknown)", r->rrx ? 1 : 0, r->main?"YES":"NO",r->prev?"YES":"NO", r->proxyreq ? "YES" : "NO"); } - /* catch proxy requests */ - if (r->proxyreq) return DECLINED; - /* mod_rewrite indicators */ - if (!strncmp(r->filename, "redirect:", 9)) return DECLINED; - if (!strncmp(r->filename, "gone:", 5)) return DECLINED; - if (!strncmp(r->filename, "passthrough:", 12)) return DECLINED; - if (!strncmp(r->filename, "forbidden:", 10)) return DECLINED; - /* If we don't have a full directory configuration, bail out. */ if (!dc->charset_source || !dc->charset_default) { @@ -190,6 +181,14 @@ return DECLINED; } + /* catch proxy requests */ + if (r->proxyreq) return DECLINED; + /* mod_rewrite indicators */ + if (!strncmp(r->filename, "redirect:", 9)) return DECLINED; + if (!strncmp(r->filename, "gone:", 5)) return DECLINED; + if (!strncmp(r->filename, "passthrough:", 12)) return DECLINED; + if (!strncmp(r->filename, "forbidden:", 10)) return DECLINED; + /* If this is a subrequest, bail out. We don't want to be setting up * translation just because something like mod_autoindex wants to find the * mime type for directory objects. @@ -204,6 +203,8 @@ return DECLINED; } + mime_type = r->content_type ? r->content_type : ap_default_type(r); + /* If mime type isn't text or message, bail out. */ if (strncasecmp(mime_type, "text/", 5) && @@ -224,18 +225,41 @@ dc && dc->charset_default ? dc->charset_default : "(none)"); } - rv = ap_xlate_open(&xlate, dc->charset_default, dc->charset_source, r->pool); + rv = ap_xlate_open(&output_xlate, dc->charset_default, dc->charset_source, r->pool); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, "can't open translation %s->%s, error %d\n", dc->charset_source, dc->charset_default, rv); return HTTP_INTERNAL_SERVER_ERROR; } - rv = ap_set_content_xlate(r, 1, xlate); + rv = ap_set_content_xlate(r, 1, output_xlate); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, - "can't set content translation, error %d\n", rv); + "can't set content output translation, error %d\n", rv); return HTTP_INTERNAL_SERVER_ERROR; + } + + switch (r->method_number) { + case M_PUT: + case M_POST: + /* Set up input translation. Note: A request body can be included + * with the OPTIONS method, but for now we don't set up translation + * of it. + */ + rv = ap_xlate_open(&input_xlate, dc->charset_source, + dc->charset_default, r->pool); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, + "can't open translation %s->%s, error %d\n", + dc->charset_default, dc->charset_source, rv); + return HTTP_INTERNAL_SERVER_ERROR; + } + rv = ap_set_content_xlate(r, 0, input_xlate); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, + "can't set content input translation, error %d\n", rv); + return HTTP_INTERNAL_SERVER_ERROR; + } } return DECLINED;