Index: HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.61 diff -u -r1.61 HttpMethodBase.java --- HttpMethodBase.java 24 Sep 2002 02:53:27 -0000 1.61 +++ HttpMethodBase.java 4 Oct 2002 17:02:53 -0000 @@ -1065,7 +1065,7 @@ } /** - * Adds a Content-Length or Transer-Encoding: Chunked + * Adds a Content-Length or Transfer-Encoding: Chunked * request header, as long as no Content-Length request header * already exists. * @@ -1532,16 +1532,18 @@ is = new WireLogInputStream(is); } InputStream result = null; - if (null != lengthHeader) { + // We use Transfer-Encoding if present and ignore Content-Length. + // RFC2616, 4.4 item number 3 + if (null != transferEncodingHeader) { + if ("chunked".equalsIgnoreCase(transferEncodingHeader.getValue())) { + result = new ChunkedInputStream(is, this); + } + } else if (null != lengthHeader) { try { int expectedLength = Integer.parseInt(lengthHeader.getValue()); result = new ContentLengthInputStream(is, expectedLength); } catch(NumberFormatException e) { // ignored - } - } else if (null != transferEncodingHeader) { - if ("chunked".equalsIgnoreCase(transferEncodingHeader.getValue())) { - result = new ChunkedInputStream(is, this); } } else if(canResponseHaveBody(statusLine.getStatusCode()) && !getName().equals(ConnectMethod.NAME)){