/** structure to aid charset translate between machine and network */
struct ap_rr_xlate {
/* contents are experimental! expect it to change! */
- /** translation handle to use when going to the network */
- apr_xlate_t *to_net;
- /** whether or not write translation is single-byte-only */
- int to_net_sb;
/** translation handle to use when coming from the network */
apr_xlate_t *from_net;
};
*/
apr_status_t ap_init_ebcdic(apr_pool_t *pool);
-/**
- * Check the Content-Type to decide if conversion is needed
- * @param r The current request
- * @return The translation handle to use for the conversion if one is needed
- */
-apr_xlate_t *ap_checkconv(request_rec *r);
-
#ifdef __cplusplus
}
#endif
* expect to be signal-ready to SIGALRM. There is no clean way to
* fix this, except to put alarm support into BUFF. -djg
*/
-#ifdef CHARSET_EBCDIC
- /* XXX:@@@ Is the generated/included output ALWAYS in text/ebcdic format? */
- ap_bsetopt(r->connection->client, BO_WXLATE, &ap_hdrs_to_ascii);
-#endif
send_parsed_content(&b, r, f);
ap_pass_brigade(f->next, b);
apr_table_get(r->headers_out, "Connection"), "close");
const char *conn = apr_table_get(r->headers_in, "Connection");
-#ifdef APACHE_XLATE
- if (r->rrx->to_net && !r->rrx->to_net_sb) {
- /* Translation is not single-byte-only, so we don't know the
- * content length. Zap the Content-Length header before the
- * following logic, as the absence of the Content-Length header
- * may affect the decision on chunked encoding.
- */
- apr_table_unset(r->headers_out,"Content-Length");
- }
-#endif /* APACHE_XLATE */
-
/* The following convoluted conditional determines whether or not
* the current connection should remain persistent after this response
* (a.k.a. HTTP Keep-Alive) and whether or not the output message
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
}
}
-#ifdef APACHE_XLATE
- /* Ensure that the proper translation handle (if any) is used when
- * sending the response document to the client. Note that on an
- * ASCII machine, ap_hdrs_to_ascii is NULL, so this will turn off
- * any translation selected by a module for content.
- */
- ap_set_content_xlate(r, 1, ap_hdrs_to_ascii);
-#endif
-
if ((custom_response = ap_response_code_string(r, idx))) {
/*
* We have a custom response output. This should only be
/* see comments in process_request_internal() */
ap_run_insert_filter(r);
-
-#ifndef APACHE_XLATE
retval = ap_invoke_handler(r);
-#else /*APACHE_XLATE*/
- {
- /* Save the output conversion setting across subrequests */
- apr_xlate_t *saved_xlate;
-
- ap_bgetopt(r->connection->client, BO_WXLATE, &saved_xlate);
- retval = ap_invoke_handler(r);
- ap_bsetopt(r->connection->client, BO_WXLATE, &saved_xlate);
- }
-#endif /*APACHE_XLATE*/
ap_finalize_sub_req_protocol(r);
return retval;
}
* the source code.
*
* For an ASCII machine, these remain NULL so that when they are stored
- * in the BUFF via ap_bsetop(BO_WXLATE or BO_RXLATE) it ensures that no
- * translation is performed.
+ * in the BUFF via ap_bsetop(BO_RXLATE) it ensures that no translation is
+ * performed.
*/
apr_xlate_t *ap_hdrs_to_ascii, *ap_hdrs_from_ascii;
{
apr_status_t rv;
- if (output) {
- r->rrx->to_net = xlate;
- if (xlate) {
- apr_xlate_get_sb(r->rrx->to_net, &r->rrx->to_net_sb);
- }
- rv = ap_bsetopt(r->connection->client, BO_WXLATE, &xlate);
- }
- else {
- r->rrx->from_net = xlate;
- rv = ap_bsetopt(r->connection->client, BO_RXLATE, &xlate);
- }
+ ap_assert(output == 0);
+
+ r->rrx->from_net = xlate;
+ rv = ap_bsetopt(r->connection->client, BO_RXLATE, &xlate);
if (rv) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "BO_%sXLATE failed",
- output ? "W" : "R");
+ "BO_RXLATE failed");
}
return rv;
return APR_SUCCESS;
}
-#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
-
-/* Check the Content-Type to decide if conversion is needed */
-apr_xlate_t *ap_checkconv(struct request_rec *r)
-{
- int convert_to_ascii;
- const char *type;
- apr_xlate_t *zero = NULL;
-
- /* To make serving of "raw ASCII text" files easy (they serve faster
- * since they don't have to be converted from EBCDIC), a new
- * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
- * If we detect one of these content types here, we simply correct
- * the type to the real text/{plain,html,...} type. Otherwise, we
- * set a flag that translation is required later on.
- */
-
- type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
- /* If no content type is set then treat it as (ebcdic) text/plain */
- convert_to_ascii = (type == NULL);
-
- /* Conversion is applied to text/ files only, if ever. */
- if (type && (strncasecmp(type, "text/", 5) == 0 ||
- strncasecmp(type, "message/", 8) == 0)) {
- if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
- sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
- r->content_type = apr_pstrcat(r->pool, "text/",
- type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
- NULL);
- else
- /* translate EBCDIC to ASCII */
- convert_to_ascii = 1;
- }
- /* Turn off conversion if it's not a text document */
- if (!convert_to_ascii) {
- ap_set_content_xlate(r, 1, zero);
- }
-
- return convert_to_ascii ? ap_locale_to_ascii : NULL;
-}
-
#endif /* CHARSET_EBCDIC */