/** * Consume the HTTP message body fully, including any metadata used to frame the body. * * @param inputStream the raw input stream * @return the exact bytes of the message body * @throws IOException if an error occurs while consuming the message body */ public byte[] consume(InputStream inputStream) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); consumeInto(inputStream, out, DEFAULT_BUFFER_SIZE); return out.toByteArray(); }
/** * Consume the HTTP message body fully, including any metadata used to frame the body. * * @param inputStream the raw input stream * @return the exact bytes of the message body * @throws IOException if an error occurs while consuming the message body */ public byte[] consume(InputStream inputStream) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); consumeInto(inputStream, out, DEFAULT_BUFFER_SIZE); return out.toByteArray(); }
/** * Read the raw HTTP message body, simultaneously writing it to the given output. * <p> * This method may not validate the full HTTP message before it starts writing it out. * To perform a full validation first, call {@link #eager()} to get an eager reader. * * @param out to write the HTTP body to * @param bufferSize size of the buffer to use for writing, if possible * @throws IOException if an error occurs while writing the message * @see BodyReader#writeDecodedTo(OutputStream, int) */ public void writeTo(OutputStream out, int bufferSize) throws IOException { framedBody.getBodyConsumer().consumeInto(asRawStream(), out, bufferSize); }
/** * Read the raw HTTP message body, simultaneously writing it to the given output. * <p> * This method may not validate the full HTTP message before it starts writing it out. * To perform a full validation first, call {@link #eager()} to get an eager reader. * * @param out to write the HTTP body to * @param bufferSize size of the buffer to use for writing, if possible * @throws IOException if an error occurs while writing the message * @see BodyReader#writeDecodedTo(OutputStream, int) */ public void writeTo(OutputStream out, int bufferSize) throws IOException { framedBody.getBodyConsumer().consumeInto(asRawStream(), out, bufferSize); }