diff options
author | Frank Liu <frank.liu@ishisystems.com> | 2014-04-17 09:17:32 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-04-17 09:17:32 +0400 |
commit | 65f345d7758d46deb82ccaeed7af38c5d498ece5 (patch) | |
tree | db209881b3c229cb48047a087040d93b504e1c7b | |
parent | f7adc48ced97d3c6849590d5622ebe1ef4f9ad31 (diff) |
BJA-483 Implement available() on TlsInputStream
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/tls/TlsInputStream.java | 6 | ||||
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsInputStream.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsInputStream.java index 9509dc4f..a2cf74e8 100644 --- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsInputStream.java +++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsInputStream.java @@ -17,6 +17,12 @@ class TlsInputStream this.handler = handler; } + public int available() + throws IOException + { + return this.handler.applicationDataAvailable(); + } + public int read(byte[] buf, int offset, int len) throws IOException { diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java index 85fdd3ec..9e6d73ae 100644 --- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java +++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java @@ -392,6 +392,12 @@ public abstract class TlsProtocol } } + protected int applicationDataAvailable() + throws IOException + { + return applicationDataQueue.size(); + } + /** * Read data from the network. The method will return immediately, if there is still some data * left in the buffer, or block until some application data has been read from the network. |