/** * @return the body of the HTTP message as a {@link ChunkedBodyContents} if the body indeed used * the chunked transfer coding. If the body was not chunked, this method returns an empty value. * @throws IOException if an error occurs while consuming the message body */ public Optional<ChunkedBodyContents> asChunkedBodyContents() throws IOException { return framedBody.use( cl -> Optional.empty(), chunked -> Optional.of(chunked.getContents(asRawStream())), ct -> Optional.empty()); }
/** * @return the body of the HTTP message as a {@link ChunkedBodyContents} if the body indeed used * the chunked transfer coding. If the body was not chunked, this method returns an empty value. * @throws IOException if an error occurs while consuming the message body */ public Optional<ChunkedBodyContents> asChunkedBodyContents() throws IOException { return framedBody.use( cl -> Optional.empty(), chunked -> Optional.of(chunked.getContents(asRawStream())), ct -> Optional.empty()); }
@Override public OptionalLong getLengthIfKnown() { try { return getFramedBody().use( cl -> OptionalLong.of(cl.getBodyLength()), chunked -> OptionalLong.empty(), ct -> OptionalLong.empty()); } catch (IOException e) { return OptionalLong.empty(); } }
@Override public OptionalLong getLengthIfKnown() { try { return getFramedBody().use( cl -> OptionalLong.of(cl.getBodyLength()), chunked -> OptionalLong.empty(), ct -> OptionalLong.empty()); } catch (IOException e) { return OptionalLong.empty(); } }