/** * Consumes the data. * * This method should be used carefully, since if the source represents an ephemeral stream, then the entity may * not be usable after this method is invoked. * @param mat the application's materializer. * @return a CompletionStage holding the data */ public CompletionStage<ByteString> consumeData(Materializer mat) { return dataStream().runFold(ByteString.empty(), ByteString::concat, mat); }
/** * Consumes the data. * * This method should be used carefully, since if the source represents an ephemeral stream, then the entity may * not be usable after this method is invoked. * @param mat the application's materializer. * @return a CompletionStage holding the data */ public CompletionStage<ByteString> consumeData(Materializer mat) { return dataStream().runFold(ByteString.empty(), ByteString::concat, mat); }
/** * Consumes the data. * * This method should be used carefully, since if the source represents an ephemeral stream, then the entity may * not be usable after this method is invoked. * @param mat the application's materializer. * @return a CompletionStage holding the data */ public CompletionStage<ByteString> consumeData(Materializer mat) { return dataStream().runFold(ByteString.empty(), ByteString::concat, mat); }
ByteString blockingToByteString(Source<ByteString, ?> bodyAsSource) { try { return bodyAsSource .runFold(ByteString.createBuilder(), ByteStringBuilder::append, materializer) .thenApply(ByteStringBuilder::result) .toCompletableFuture() .get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }
ByteString blockingToByteString(Source<ByteString, ?> bodyAsSource) { try { return bodyAsSource .runFold(ByteString.createBuilder(), ByteStringBuilder::append, materializer) .thenApply(ByteStringBuilder::result) .toCompletableFuture() .get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }