/** * This method is used to consume bytes from the provided cursor. * Consuming of bytes from the cursor should be done in such a * way that it does not block. So typically only the number of * ready bytes in the <code>ByteCursor</code> object should be * read. If there are no ready bytes then this will return. * * @param cursor used to consume the bytes from the HTTP pipeline */ public void consume(ByteCursor cursor) throws IOException { ByteCounter counter = new ByteCounter(cursor); while(counter.isReady()) { if(consumer.isFinished()) { break; } consumer.consume(counter); } }
/** * Pushes the provided data on to the cursor. Data pushed on to * the cursor will be the next data read from the cursor. This * complements the <code>reset</code> method which will reset * the cursors position on a stream. Allowing data to be pushed * on to the cursor allows more flexibility. * * @param data this is the data to be pushed on to the cursor */ public void push(byte[] data) throws IOException { push(data, 0, data.length); }
/** * Reads a block of bytes from the underlying stream. This will * read up to the requested number of bytes from the underlying * stream. If there are no ready bytes on the stream this can * return zero, representing the fact that nothing was read. * * @param data this is the array to read the bytes in to * * @return this returns the number of bytes read from the stream */ public int read(byte[] data) throws IOException { return read(data, 0, data.length); }
/** * This method is used to consume bytes from the provided cursor. * Consuming of bytes from the cursor should be done in such a * way that it does not block. So typically only the number of * ready bytes in the <code>ByteCursor</code> object should be * read. If there are no ready bytes then this will return. * * @param cursor used to consume the bytes from the HTTP pipeline */ public void consume(ByteCursor cursor) throws IOException { ByteCounter counter = new ByteCounter(cursor); while(counter.isReady()) { if(consumer.isFinished()) { break; } consumer.consume(counter); } }
/** * Reads a block of bytes from the underlying stream. This will * read up to the requested number of bytes from the underlying * stream. If there are no ready bytes on the stream this can * return zero, representing the fact that nothing was read. * * @param data this is the array to read the bytes in to * * @return this returns the number of bytes read from the stream */ public int read(byte[] data) throws IOException { return read(data, 0, data.length); }
/** * Pushes the provided data on to the cursor. Data pushed on to * the cursor will be the next data read from the cursor. This * complements the <code>reset</code> method which will reset * the cursors position on a stream. Allowing data to be pushed * on to the cursor allows more flexibility. * * @param data this is the data to be pushed on to the cursor */ public void push(byte[] data) throws IOException { push(data, 0, data.length); }