/** * This is determined finished when the body has been consumed. If only the header has been * consumed then the body will be created using the header information, the body is then read from * the cursor, which may read nothing for an empty body. * * @return this returns true if the entity has been built */ public boolean isFinished() { if (header.isFinished()) { if (body == null) { body = factory.getInstance(); } return body.isFinished(); } return false; }
/** * This consumes the header and body from the cursor. The header is consumed first followed by the * body if there is any. There is a body of there is a Content-Length or a Transfer-Encoding * header present. If there is no body then a substitute body is given which has an empty input * stream. * * @param cursor used to consumed the bytes for the entity */ public void consume(Cursor cursor) throws IOException { while (cursor.isReady()) { if (header.isFinished()) { if (body == null) { body = factory.getInstance(); } body.consume(cursor); if (body.isFinished()) { break; } } else { header.consume(cursor); } } if (header.isFinished()) { if (body == null) { expect.execute(header); body = factory.getInstance(); } builder.setBody(body); builder.setHeader(header); } }