Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 59286 invoked from network); 8 Jul 2003 11:51:49 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 8 Jul 2003 11:51:49 -0000 Received: (qmail 8413 invoked by uid 97); 8 Jul 2003 11:54:14 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 8406 invoked from network); 8 Jul 2003 11:54:14 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 8 Jul 2003 11:54:14 -0000 Received: (qmail 58993 invoked by uid 500); 8 Jul 2003 11:51:46 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 58962 invoked by uid 500); 8 Jul 2003 11:51:46 -0000 Received: (qmail 58959 invoked from network); 8 Jul 2003 11:51:46 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 8 Jul 2003 11:51:46 -0000 Received: (qmail 73072 invoked by uid 1633); 8 Jul 2003 11:51:45 -0000 Date: 8 Jul 2003 11:51:45 -0000 Message-ID: <20030708115145.73071.qmail@icarus.apache.org> From: mbecke@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mbecke 2003/07/08 04:51:45 Modified: httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java Log: Multiple transfer encoding headers are now handled properly. PR: 21378 Submitted by: Oleg Kalnichevski and Michael Becke Revision Changes Path 1.161 +30 -8 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java Index: HttpMethodBase.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- HttpMethodBase.java 5 Jul 2003 18:30:27 -0000 1.160 +++ HttpMethodBase.java 8 Jul 2003 11:51:45 -0000 1.161 @@ -2013,27 +2013,49 @@ LOG.trace("enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)"); responseBody = null; // is this desired? - Header transferEncodingHeader = getResponseHeader("Transfer-Encoding"); InputStream is = conn.getResponseInputStream(); if (Wire.enabled()) { is = new WireLogInputStream(is); } InputStream result = null; + Header[] transferEncodingHeaders = responseHeaders.getHeaders("Transfer-Encoding"); // We use Transfer-Encoding if present and ignore Content-Length. // RFC2616, 4.4 item number 3 - if (transferEncodingHeader != null) { - if ("chunked".equalsIgnoreCase(transferEncodingHeader.getValue())) { + if (transferEncodingHeaders.length > 0) { + boolean containsChunked = false; + for (int i = 0; i < transferEncodingHeaders.length; i++) { + String encoding = transferEncodingHeaders[i].getValue(); + if ("chunked".equalsIgnoreCase(encoding)) { + containsChunked = true; + break; + } else if ("identity".equalsIgnoreCase(encoding)) { + //No content transformation needed + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Unsupported transfer encoding: " + encoding); + } + } + } + if (containsChunked) { // Some HTTP servers do not bother sending a closing chunk // if response body is empty if (conn.isResponseAvailable(conn.getSoTimeout())) { result = new ChunkedInputStream(is, this); } else { - if (this.isStrictMode()) { + if (isStrictMode()) { throw new HttpException("Chunk-encoded body declared but not sent"); } else { LOG.warn("Chunk-encoded body missing"); } } + } else { + if (isStrictMode() && LOG.isWarnEnabled()) { + LOG.warn("Transfer-Encoding is set but does not contain \"chunked\": " + + getResponseHeader("Transfer-Encoding")); + } + // we assume that the response connection will be terminated by closing + // the socket as per RFC 2616, 3.6 + result = is; } } else { int expectedLength = getResponseContentLength(); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org