@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
receiveAndCheckResponse(is); return new BlobInputStream(is, blobKey);
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
receiveAndCheckResponse(is); return new BlobInputStream(is, null);
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
receiveAndCheckGetResponse(is); return new BlobInputStream(is, blobKey, os);
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
receiveAndCheckGetResponse(is); return new BlobInputStream(is, blobKey, os);
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
receiveAndCheckGetResponse(is); return new BlobInputStream(is, blobKey, os);
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final BlobKey computedKey = new BlobKey(this.md.digest()); if (!computedKey.equals(this.blobKey)) { throw new IOException("Detected data corruption during transfer"); } } } return read; }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final BlobKey computedKey = new BlobKey(this.md.digest()); if (!computedKey.equals(this.blobKey)) { throw new IOException("Detected data corruption during transfer"); } } } return read; }