From: Martin Kraemer Date: Fri, 12 Apr 2002 12:36:53 +0000 (+0000) Subject: Fix EOF detection in new proxy dechunking code. Before, we barfed when we got X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca76036474f0b5d399b5ba5d6036f832d1a6a239;p=thirdparty%2Fapache%2Fhttpd.git Fix EOF detection in new proxy dechunking code. Before, we barfed when we got EOF (stripped down to '\xFF') instead of CRLF. Also avoid a conversion problem for EBCDIC hosts. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@94622 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/modules/proxy/proxy_util.c b/src/modules/proxy/proxy_util.c index dd95471c858..c0e685e0f01 100644 --- a/src/modules/proxy/proxy_util.c +++ b/src/modules/proxy/proxy_util.c @@ -442,7 +442,7 @@ table *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f) return resp_hdrs; } -/* read data from f, write it to: +/* read data from (socket BUFF*) f, write it to: * - c->fp, if it is open * - r->connection->client, if nowrite == 0 */ @@ -474,8 +474,6 @@ long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c, off_t len, int #ifdef CHARSET_EBCDIC /* The cache copy is ASCII, not EBCDIC, even for text/html) */ ap_bsetflag(f, B_ASCII2EBCDIC | B_EBCDIC2ASCII, 0); - if (c != NULL && c->fp != NULL) - ap_bsetflag(c->fp, B_ASCII2EBCDIC | B_EBCDIC2ASCII, 0); ap_bsetflag(con->client, B_ASCII2EBCDIC | B_EBCDIC2ASCII, 0); #endif @@ -553,24 +551,30 @@ long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c, off_t len, int /* soak up trailing CRLF */ if (0 == remaining) { - char ch; + int ch; /* int because it may hold an EOF */ /* - * For EBCDIC, the proxy has configured the BUFF layer to - * transparently pass the ascii characters thru (also writing - * an ASCII copy to the cache, where appropriate). - * Therefore, we see here an ASCII-CRLF (\015\012), - * not an EBCDIC-CRLF (\r\n). - */ - if ((ch = ap_bgetc(f)) == '\015') { /* _ASCII_ CR */ - ch = ap_bgetc(f); + * For EBCDIC, the proxy has configured the BUFF layer to + * transparently pass the ascii characters thru (also writing + * an ASCII copy to the cache, where appropriate). + * Therefore, we see here an ASCII-CRLF (\015\012), + * not an EBCDIC-CRLF (\r\n). + */ + if ((ch = ap_bgetc(f)) == EOF) { + /* EOF detected */ + n = 0; } - if (ch != '\012') { - n = -1; + else + { + if (ch == '\015') { /* _ASCII_ CR */ + ch = ap_bgetc(f); + } + if (ch != '\012') { + n = -1; + } } } } - /* otherwise read block normally */ else { if (-1 == len) {