
oscaremma at gmail
May 15, 2008, 10:54 AM
Post #1 of 2
(99 views)
Permalink
|
|
[PATCH] Response to TRACE garbled from EBCDIC platform
|
|
The response to TRACE when "TraceEnable Off" is not used on an EBCDIC platform is partially in ASCII and partially in EBCDIC (part readable, part garbage). routine ap_send_http_trace in modules/http_filters.c recreates the request and echoes it back when TRACE is requested. form_header_field (from apr_table_do) has the necessary EBCDIC conditional code to translate those fields to ASCII. But, the request header and ending CRLF are created outside of that call, and need to translated as well. Index: httpd.h =================================================================== --- httpd.h (revision 579232) +++ httpd.h (working copy) @@ -649,6 +649,8 @@ #define LF '\n' #define CRLF "\r\n" #endif /* APR_CHARSET_EBCDIC */ +/* Useful for common code with either platform charset. */ +#define CRLF_ASCII "\015\012" /** * @defgroup values_request_rec_body Possible values for request_rec.read_body Index: http_filters.c =================================================================== --- http_filters.c (revision 656736) +++ http_filters.c (working copy) @@ -1058,12 +1058,23 @@ /* Now we recreate the request, and echo it back */ bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); +#if APR_CHARSET_EBCDIC + { + char *tmp; + apr_size_t len; + len = strlen(r->the_request); + tmp = apr_pmemdup(r->pool, r->the_request, len); + ap_xlate_proto_to_ascii(tmp, len); + apr_brigade_putstrs(bb, NULL, NULL, tmp, CRLF_ASCII, NULL); + } +#else apr_brigade_putstrs(bb, NULL, NULL, r->the_request, CRLF, NULL); +#endif h.pool = r->pool; h.bb = bb; apr_table_do((int (*) (void *, const char *, const char *)) form_header_field, (void *) &h, r->headers_in, NULL); - apr_brigade_puts(bb, NULL, NULL, CRLF); + apr_brigade_puts(bb, NULL, NULL, CRLF_ASCII); /* If configured to accept a body, echo the body */ if (bodylen) {
|