Mercurial Hosting > luan
changeset 1060:957f758dcffc
fix JBuffer.get()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 08 Nov 2016 05:51:00 -0700 |
parents | 013939bfc9e8 |
children | c880589715c7 |
files | src/org/eclipse/jetty/io/JBuffer.java src/org/eclipse/jetty/server/AbstractHttpConnection.java |
diffstat | 2 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/JBuffer.java Tue Nov 08 05:39:33 2016 -0700 +++ b/src/org/eclipse/jetty/io/JBuffer.java Tue Nov 08 05:51:00 2016 -0700 @@ -98,14 +98,8 @@ } - public int get(byte[] b, int offset, int length) { - int remaining = bb.remaining(); - if( remaining == 0 ) - return -1; - if( length > remaining ) - length = remaining; + public void get(byte[] b, int offset, int length) { bb.get(b,offset,length); - return length; } @@ -170,7 +164,7 @@ return n; } - public final byte[] asArray() { + private final byte[] asArray() { byte[] bytes = new byte[remaining()]; bb.duplicate().get(bytes); return bytes;
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Tue Nov 08 05:39:33 2016 -0700 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Tue Nov 08 05:51:00 2016 -0700 @@ -879,13 +879,19 @@ @Override public int read(byte[] b, int off, int len) throws IOException { - int l = -1; JBuffer content = _parser.blockForContent(getMaxIdleTime()); - if (content!=null) - l = content.get(b, off, len); - else if (_earlyEOF) + if (content!=null) { + int remaining = content.remaining(); + if( remaining == 0 ) + return -1; + if( len > remaining ) + len = remaining; + content.get(b, off, len); + return len; + } else if (_earlyEOF) throw new EofException("early EOF"); - return l; + else + return -1; } @Override