Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 59066 invoked from network); 22 Mar 2010 21:51:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Mar 2010 21:51:12 -0000 Received: (qmail 76645 invoked by uid 500); 22 Mar 2010 21:51:12 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 76616 invoked by uid 500); 22 Mar 2010 21:51:12 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 76608 invoked by uid 99); 22 Mar 2010 21:51:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Mar 2010 21:51:12 +0000 X-ASF-Spam-Status: No, hits=-0.6 required=10.0 tests=AWL,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [69.49.121.196] (HELO mail90c0.megamailservers.com) (69.49.121.196) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Mar 2010 21:51:03 +0000 X-Authenticated-User: james-nospam.leighnet.ca Received: from [192.168.0.15] (CPE0015e912e45f-CM001404d93658.cpe.net.cable.rogers.com [99.233.108.45]) (authenticated bits=0) by mail90c0.megamailservers.com (8.13.6/8.13.1) with ESMTP id o2MLoeGv014324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 22 Mar 2010 17:50:41 -0400 Subject: Re: [HttpCore] HttpCore 4.1-beta1 release preview From: James Leigh To: HttpComponents Project In-Reply-To: <4BA620F3.6070104@apache.org> References: <4BA620F3.6070104@apache.org> Content-Type: text/plain; charset="UTF-8" Date: Mon, 22 Mar 2010 17:50:39 -0400 Message-ID: <1269294639.2369.37.camel@isaac> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit On Sun, 2010-03-21 at 14:36 +0100, Oleg Kalnichevski wrote: > Folks > > Please DO try to find a few minutes to review the release notes and > release packages for the coming HttpCore 4.1-beta1 > > Release notes: > http://people.apache.org/~olegk/httpcore-4.1-beta1-preview/RELEASE_NOTES.txt > > Release packages: > http://people.apache.org/~olegk/httpcore-4.1-beta1-preview/ > > If I hear no complaints I will proceed with building the official > release packages in a few days. > > Oleg > Oleg, can you check on LengthDelimitedDecoder logic for Content-Length: 0? Looking at the code below (from the preview release) I don't think it will ever change the status to complete. On the line 95 dst.limit(newLimit), the limit is set to zero, so the next read operation returns zero. This causes a perpetual read of zero bytes and never completes. Perhaps it should have another condition to complete immediately if the content length is zero? Normally, I would create a bug for this, but because of the timing I wanted to bring this up for discussion right away. -- Thanks, James public class LengthDelimitedDecoder extends AbstractContentDecoder implements FileContentDecoder { private final long contentLength; private long len; public LengthDelimitedDecoder( final ReadableByteChannel channel, final SessionInputBuffer buffer, final HttpTransportMetricsImpl metrics, long contentLength) { super(channel, buffer, metrics); if (contentLength < 0) { throw new IllegalArgumentException("Content length may not be negative"); } this.contentLength = contentLength; } public int read(final ByteBuffer dst) throws IOException { if (dst == null) { throw new IllegalArgumentException("Byte buffer may not be null"); } if (this.completed) { return -1; } int lenRemaining = (int) (this.contentLength - this.len); int bytesRead; if (this.buffer.hasData()) { int maxLen = Math.min(lenRemaining, this.buffer.length()); bytesRead = this.buffer.read(dst, maxLen); } else { if (dst.remaining() > lenRemaining) { int oldLimit = dst.limit(); int newLimit = oldLimit - (dst.remaining() - lenRemaining); dst.limit(newLimit); bytesRead = this.channel.read(dst); dst.limit(oldLimit); } else { bytesRead = this.channel.read(dst); } if (bytesRead > 0) { this.metrics.incrementBytesTransferred(bytesRead); } } if (bytesRead == -1) { this.completed = true; return -1; } this.len += bytesRead; if (this.len >= this.contentLength) { this.completed = true; } return bytesRead; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org