diff --git a/include/httpd.h b/include/httpd.h index 165f713252..0e7ddfd265 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -594,6 +594,7 @@ typedef struct request_rec request_rec; struct ap_rr_xlate { /* contents are experimental! expect it to change! */ ap_xlate_t *to_net; + int to_net_sb; /* whether or not write translation is single-byte-only */ ap_xlate_t *from_net; }; #endif /*APACHE_XLATE*/ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index c4838c10ca..14c638d7a1 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -333,6 +333,17 @@ API_EXPORT(int) ap_set_keepalive(request_rec *r) ap_table_get(r->headers_out, "Connection"), "close"); const char *conn = ap_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. + */ + ap_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 diff --git a/server/util_charset.c b/server/util_charset.c index 8a613f9075..b6bb0dfd83 100644 --- a/server/util_charset.c +++ b/server/util_charset.c @@ -103,6 +103,9 @@ API_EXPORT(ap_status_t) ap_set_content_xlate(request_rec *r, int output, if (output) { r->rrx->to_net = xlate; + if (xlate) { + ap_xlate_get_sb(r->rrx->to_net, &r->rrx->to_net_sb); + } rv = ap_bsetopt(r->connection->client, BO_WXLATE, &xlate); } else {