@Override public InputStream getContent() throws IOException { return new EofSensorInputStream(wrappedEntity.getContent(), this); }
@Override public int read(byte[] b, int off, int len) throws IOException { int l = -1; if (isReadAllowed()) { try { l = wrappedStream.read(b, off, len); checkEOF(l); } catch (IOException ex) { checkAbort(); throw ex; } } return l; }
@Override public void close() throws IOException { // tolerate multiple calls to close() selfClosed = true; checkClose(); }
@Override public int available() throws IOException { int a = 0; // not -1 if (isReadAllowed()) { try { a = wrappedStream.available(); // no checkEOF() here, available() can't trigger EOF } catch (IOException ex) { checkAbort(); throw ex; } } return a; }
/** * Same as {@link #close close()}. */ public void releaseConnection() throws IOException { this.close(); }
/** * Aborts this stream. * This is a special version of {@link #close close()} which prevents * re-use of the underlying connection, if any. Calling this method * indicates that there should be no attempt to read until the end of * the stream. */ public void abortConnection() throws IOException { // tolerate multiple calls selfClosed = true; checkAbort(); }
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int available() throws IOException { int a = 0; // not -1 if (isReadAllowed()) { try { a = wrappedStream.available(); // no checkEOF() here, available() can't trigger EOF } catch (IOException ex) { checkAbort(); throw ex; } } return a; }
/** * Same as {@link #close close()}. */ @Override public void releaseConnection() throws IOException { close(); }
/** * Aborts this stream. * This is a special version of {@link #close close()} which prevents * re-use of the underlying connection, if any. Calling this method * indicates that there should be no attempt to read until the end of * the stream. */ public void abortConnection() throws IOException { // tolerate multiple calls selfClosed = true; checkAbort(); }
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(byte[] b) throws IOException { int l = -1; if (isReadAllowed()) { try { l = wrappedStream.read(b); checkEOF(l); } catch (IOException ex) { checkAbort(); throw ex; } } return l; }
@Override public int available() throws IOException { int a = 0; // not -1 if (isReadAllowed()) { try { a = wrappedStream.available(); // no checkEOF() here, available() can't trigger EOF } catch (final IOException ex) { checkAbort(); throw ex; } } return a; }
@Override public InputStream getContent() throws IOException { return new EofSensorInputStream(wrappedEntity.getContent(), this); }
@Override public void close() throws IOException { // tolerate multiple calls to close() selfClosed = true; checkClose(); }
/** * Same as {@link #close close()}. */ public void releaseConnection() throws IOException { this.close(); }
/** * Aborts this stream. * This is a special version of {@link #close close()} which prevents * re-use of the underlying connection, if any. Calling this method * indicates that there should be no attempt to read until the end of * the stream. */ public void abortConnection() throws IOException { // tolerate multiple calls selfClosed = true; checkAbort(); }
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read() throws IOException { int l = -1; if (isReadAllowed()) { try { l = wrappedStream.read(); checkEOF(l); } catch (IOException ex) { checkAbort(); throw ex; } } return l; }
@Override public int available() throws IOException { int a = 0; // not -1 if (isReadAllowed()) { try { a = wrappedStream.available(); // no checkEOF() here, available() can't trigger EOF } catch (final IOException ex) { checkAbort(); throw ex; } } return a; }