List of usage examples for org.apache.cordova.squareup.okhttp.internal Util readSingleByte
public static int readSingleByte(InputStream in) throws IOException
From source file:com.squareup.okhttp.internal.spdy.NameValueBlockReader.java
License:Apache License
NameValueBlockReader(final InputStream in) { // Limit the inflater input stream to only those bytes in the Name/Value block. We cut the // inflater off at its source because we can't predict the ratio of compressed bytes to // uncompressed bytes. InputStream throttleStream = new InputStream() { @Override//from w w w . j av a2s . c o m public int read() throws IOException { return Util.readSingleByte(this); } @Override public int read(byte[] buffer, int offset, int byteCount) throws IOException { byteCount = Math.min(byteCount, compressedLimit); int consumed = in.read(buffer, offset, byteCount); compressedLimit -= consumed; return consumed; } @Override public void close() throws IOException { in.close(); } }; // Subclass inflater to install a dictionary when it's needed. Inflater inflater = new Inflater() { @Override public int inflate(byte[] buffer, int offset, int count) throws DataFormatException { int result = super.inflate(buffer, offset, count); if (result == 0 && needsDictionary()) { setDictionary(Spdy3.DICTIONARY); result = super.inflate(buffer, offset, count); } return result; } }; fillableInflaterInputStream = new FillableInflaterInputStream(throttleStream, inflater); nameValueBlockIn = new DataInputStream(fillableInflaterInputStream); }