private synchronized int checkEOF(int n) { if (n == -1) { closeOutputStreamQuietly(); mResponseHandler.onEOF(); mEofSeen = true; } return n; }
/** * Handles reporting an {@link IOException}. We do this so we can centralize the logic while still * maintaining the ability of the catch clause to throw. * @param ex * @return */ private IOException handleIOException(IOException ex) { mResponseHandler.onError(ex); return ex; }
private void reportDecodedSizeIfApplicable() { if (mDecompressedCounter != null) { long currentCount = mDecompressedCounter.getCount(); int delta = (int)(currentCount - mLastDecompressedCount); mResponseHandler.onReadDecoded(delta); mLastDecompressedCount = currentCount; } }
@Override public int read() throws IOException { try { int result = checkEOF(in.read()); if (result != -1) { mResponseHandler.onRead(1); writeToOutputStream(result); } return result; } catch (IOException ex) { throw handleIOException(ex); } }
@Override public int read(byte[] b, int off, int len) throws IOException { try { int result = checkEOF(in.read(b, off, len)); if (result != -1) { mResponseHandler.onRead(result); writeToOutputStream(b, off, result); } return result; } catch (IOException ex) { throw handleIOException(ex); } }
if (peerManager != null) { if (availableInputStream == null) { responseHandler.onEOF(); return null;