From 4b29f1870361d77b2d1d873fa17928a663665bb8 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 3 Jun 2012 11:27:54 +0200 Subject: [PATCH] Removed constructors that take the "compressed" parameter (compression has been removed from the specification). Added constructor that takes byte[], offset and length. --- .../eclipse/jetty/spdy/api/BytesDataInfo.java | 27 +++++++++++-------- .../jetty/spdy/api/StringDataInfo.java | 7 +---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java index f2150846ca5..beeb9ef7606 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java @@ -23,39 +23,44 @@ import java.nio.ByteBuffer; */ public class BytesDataInfo extends DataInfo { - private byte[] bytes; - private int offset; + private final byte[] bytes; + private final int offset; + private final int length; + private int index; public BytesDataInfo(byte[] bytes, boolean close) { - this(bytes, close, false); + this(bytes, 0, bytes.length, close); } - public BytesDataInfo(byte[] bytes, boolean close, boolean compress) + public BytesDataInfo(byte[] bytes, int offset, int length, boolean close) { - super(close, compress); + super(close, false); this.bytes = bytes; + this.offset = offset; + this.length = length; + this.index = offset; } @Override public int length() { - return bytes.length; + return length; } @Override public int available() { - return length() - offset; + return length - index + offset; } @Override public int readInto(ByteBuffer output) { int space = output.remaining(); - int length = Math.min(available(), space); - output.put(bytes, offset, length); - offset += length; - return length; + int chunk = Math.min(available(), space); + output.put(bytes, index, chunk); + index += chunk; + return chunk; } } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java index 41e9e62330a..b6a73cb6b16 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java @@ -25,11 +25,6 @@ public class StringDataInfo extends BytesDataInfo { public StringDataInfo(String string, boolean close) { - this(string, close, false); - } - - public StringDataInfo(String string, boolean close, boolean compress) - { - super(string.getBytes(Charset.forName("UTF-8")), close, compress); + super(string.getBytes(Charset.forName("UTF-8")), close); } }