@Override public Source<ByteString, ?> dataStream() { return Source.<ByteString>single(data); }
/** * Convert the given source of ByteStrings to a chunked entity. * * @param data The source. * @param contentType The optional content type. * @return The ByteStrings. */ public static final HttpEntity chunked(Source<ByteString, ?> data, Optional<String> contentType) { return new Chunked(data.map(HttpChunk.Chunk::new), contentType); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(resourceName), inline, fileMimeTypes); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType)); } }
/** * 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); }
@Override public Source<ByteString, ?> dataStream() { return chunks.<ByteString>collect(new PFBuilder<HttpChunk, ByteString>() .match(HttpChunk.Chunk.class, HttpChunk.Chunk::data) .build() ); }
/** * Convert the given source of ByteStrings to a chunked entity. * * @param data The source. * @param contentType The optional content type. * @return The ByteStrings. */ public static final HttpEntity chunked(Source<ByteString, ?> data, Optional<String> contentType) { return new Chunked(data.map(HttpChunk.Chunk::new), contentType); }
@Override public Source<ByteString, ?> dataStream() { return Source.<ByteString>single(data); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType)); } }
/** * 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); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(resourceName), inline, fileMimeTypes); }
@Override public Source<ByteString, ?> dataStream() { return chunks.<ByteString>collect(new PFBuilder<HttpChunk, ByteString>() .match(HttpChunk.Chunk.class, HttpChunk.Chunk::data) .build() ); }
/** * Convert the given source of ByteStrings to a chunked entity. * * @param data The source. * @param contentType The optional content type. * @return The ByteStrings. */ public static final HttpEntity chunked(Source<ByteString, ?> data, Optional<String> contentType) { return new Chunked(data.map(HttpChunk.Chunk::new), contentType); }
@Override public Source<ByteString, ?> dataStream() { return Source.<ByteString>single(data); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType)); } }
/** * 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); }
@Override public Source<ByteString, ?> dataStream() { return chunks.<ByteString>collect(new PFBuilder<HttpChunk, ByteString>() .match(HttpChunk.Chunk.class, HttpChunk.Chunk::data) .build() ); }
@Override @SuppressWarnings("unchecked") public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Streamed(data.asScala(), /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an unchecked cast here to get it to typecheck */ (scala.Option) OptionConverters.toScala(contentLength), OptionConverters.toScala(contentType)); } }
@Override @SuppressWarnings("unchecked") public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Streamed(data.asScala(), /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an unchecked cast here to get it to typecheck */ (scala.Option) OptionConverters.toScala(contentLength), OptionConverters.toScala(contentType)); } }
@Override @SuppressWarnings("unchecked") public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Streamed(data.asScala(), /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an unchecked cast here to get it to typecheck */ (scala.Option) OptionConverters.toScala(contentLength), OptionConverters.toScala(contentType)); } }