@Override public String toString() { return asString(UTF_8); } }
/** * Convert the decoded body to a String using the provided charset. * * @param charset body's charset * @return decoded body as a String */ public String asString(Charset charset) { return new String(getData(), charset); }
public ChunkedBodyContents getContents(InputStream inputStream) throws IOException { List<ChunkedBodyContents.Chunk> chunks = new ArrayList<>(); AtomicReference<RawHttpHeaders> headersRef = new AtomicReference<>(); bodyParser.parseChunkedBody(inputStream, chunks::add, headersRef::set); return new ChunkedBodyContents(chunks, headersRef.get()); }
/** * @return the message body (after decoding). */ public byte[] getData() { long totalSize = size(); // this will result in an ArithmeticException if the totalSize does not fit into an int byte[] result = new byte[Math.toIntExact(totalSize)]; int offset = 0; for (Chunk chunk : chunks) { System.arraycopy(chunk.data, 0, result, offset, chunk.size()); offset += chunk.size(); } return result; }
public ChunkedBodyContents getContents(InputStream inputStream) throws IOException { List<ChunkedBodyContents.Chunk> chunks = new ArrayList<>(); AtomicReference<RawHttpHeaders> headersRef = new AtomicReference<>(); bodyParser.parseChunkedBody(inputStream, chunks::add, headersRef::set); return new ChunkedBodyContents(chunks, headersRef.get()); }
/** * @return the message body (after decoding). */ public byte[] getData() { long totalSize = size(); // this will result in an ArithmeticException if the totalSize does not fit into an int byte[] result = new byte[Math.toIntExact(totalSize)]; int offset = 0; for (Chunk chunk : chunks) { System.arraycopy(chunk.data, 0, result, offset, chunk.size()); offset += chunk.size(); } return result; }
/** * Convert the decoded body to a String using the provided charset. * * @param charset body's charset * @return decoded body as a String */ public String asString(Charset charset) { return new String(getData(), charset); }
@Override public String toString() { return asString(UTF_8); } }