You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/09/08 21:50:51 UTC
svn commit: r995230 - in /httpcomponents/httpcore/branches/4.0.x:
RELEASE_NOTES.txt httpcore-nio/
httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
Author: olegk
Date: Wed Sep 8 19:50:51 2010
New Revision: 995230
URL: http://svn.apache.org/viewvc?rev=995230&view=rev
Log:
HTTPCORE-231: Fixed incorrect handling of HTTP entities by non-blocking LengthDelimitedDecoder when the Content-Length value is larger than Integer.MAX_VALUE
Modified:
httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
httpcomponents/httpcore/branches/4.0.x/httpcore-nio/ (props changed)
httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
Modified: httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt?rev=995230&r1=995229&r2=995230&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt Wed Sep 8 19:50:51 2010
@@ -1,5 +1,9 @@
Changes since 4.0.1
+* [HTTPCORE-231] Fixed incorrect handling of HTTP entities by non-blocking LengthDelimitedDecoder
+ when the Content-Length value is larger than Integer.MAX_VALUE.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-229] AbstractSessionInputBuffer#readLine(CharArrayBuffer) returns incorrect
number of characters read by the method when using non-standard HTTP element charset.
Contributed by Oleg Kalnichevski <olegk at apache.org>
Propchange: httpcomponents/httpcore/branches/4.0.x/httpcore-nio/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 8 19:50:51 2010
@@ -1 +1 @@
-/httpcomponents/httpcore/trunk/httpcore-nio:963844
+/httpcomponents/httpcore/trunk/httpcore-nio:963844,995221-995226
Modified: httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?rev=995230&r1=995229&r2=995230&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java Wed Sep 8 19:50:51 2010
@@ -82,16 +82,16 @@ public class LengthDelimitedDecoder exte
if (this.completed) {
return -1;
}
- int lenRemaining = (int) (this.contentLength - this.len);
+ int chunk = (int) Math.min((this.contentLength - this.len), Integer.MAX_VALUE);
int bytesRead;
if (this.buffer.hasData()) {
- int maxLen = Math.min(lenRemaining, this.buffer.length());
+ int maxLen = Math.min(chunk, this.buffer.length());
bytesRead = this.buffer.read(dst, maxLen);
} else {
- if (dst.remaining() > lenRemaining) {
+ if (dst.remaining() > chunk) {
int oldLimit = dst.limit();
- int newLimit = oldLimit - (dst.remaining() - lenRemaining);
+ int newLimit = oldLimit - (dst.remaining() - chunk);
dst.limit(newLimit);
bytesRead = this.channel.read(dst);
dst.limit(oldLimit);
@@ -125,16 +125,16 @@ public class LengthDelimitedDecoder exte
return -1;
}
- int lenRemaining = (int) (this.contentLength - this.len);
+ int chunk = (int) Math.min((this.contentLength - this.len), Integer.MAX_VALUE);
long bytesRead;
if (this.buffer.hasData()) {
- int maxLen = Math.min(lenRemaining, this.buffer.length());
+ int maxLen = Math.min(chunk, this.buffer.length());
dst.position(position);
bytesRead = this.buffer.read(dst, maxLen);
} else {
- if (count > lenRemaining) {
- count = lenRemaining;
+ if (count > chunk) {
+ count = chunk;
}
if (this.channel.isOpen()) {
if(dst.size() < position)