public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.anyContent(maxLength); } }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.default_(maxLength); } }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { if (maxLength != -1) throw new IllegalArgumentException("Empty BodyParser's maxLength argument is ignored so it must have a value of -1, was: " + maxLength); return play.core.j.JavaParsers.empty(); } }
/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) { play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
@Override protected final Accumulator<ByteString, F.Either<Result, A>> apply1(Http.RequestHeader request) { Accumulator<ByteString, ByteString> byteStringByteStringAccumulator = Accumulator.strict( maybeStrictBytes -> CompletableFuture.completedFuture(maybeStrictBytes.orElse(ByteString.empty())), Sink.fold(ByteString.empty(), ByteString::concat) ); Accumulator<ByteString, F.Either<Result, A>> byteStringEitherAccumulator = byteStringByteStringAccumulator.mapFuture(bytes -> { try { return CompletableFuture.completedFuture(F.Either.Right(parse(request, bytes))); } catch (Exception e) { return errorHandler.onClientError(request, Status$.MODULE$.BAD_REQUEST(), errorMessage + ": " + e.getMessage()) .thenApply(F.Either::<Result, A>Left); } }, JavaParsers.trampoline()); return byteStringEitherAccumulator; }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.formUrlEncoded(maxLength); } }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.json(maxLength); } }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.raw(maxLength); } }
public play.api.mvc.BodyParser<Http.RequestBody> parser(long maxLength) { return play.core.j.JavaParsers.multipartFormData(maxLength); } }
/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) { play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
@Override protected final Accumulator<ByteString, F.Either<Result, A>> apply1(Http.RequestHeader request) { Accumulator<ByteString, ByteString> byteStringByteStringAccumulator = Accumulator.strict( maybeStrictBytes -> CompletableFuture.completedFuture(maybeStrictBytes.orElse(ByteString.empty())), Sink.fold(ByteString.empty(), ByteString::concat) ); Accumulator<ByteString, F.Either<Result, A>> byteStringEitherAccumulator = byteStringByteStringAccumulator.mapFuture(bytes -> { try { return CompletableFuture.completedFuture(F.Either.Right(parse(request, bytes))); } catch (Exception e) { return errorHandler.onClientError(request, Status$.MODULE$.BAD_REQUEST(), errorMessage + ": " + e.getMessage()) .thenApply(F.Either::<Result, A>Left); } }, JavaParsers.trampoline()); return byteStringEitherAccumulator; }
/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) { play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
@Override protected final Accumulator<ByteString, F.Either<Result, A>> apply1(Http.RequestHeader request) { Accumulator<ByteString, ByteString> byteStringByteStringAccumulator = Accumulator.strict( maybeStrictBytes -> CompletableFuture.completedFuture(maybeStrictBytes.orElse(ByteString.empty())), Sink.fold(ByteString.empty(), ByteString::concat) ); Accumulator<ByteString, F.Either<Result, A>> byteStringEitherAccumulator = byteStringByteStringAccumulator.mapFuture(bytes -> { try { return CompletableFuture.completedFuture(F.Either.Right(parse(request, bytes))); } catch (Exception e) { return errorHandler.onClientError(request, Status$.MODULE$.BAD_REQUEST(), errorMessage + ": " + e.getMessage()) .thenApply(F.Either::<Result, A>Left); } }, JavaParsers.trampoline()); return byteStringEitherAccumulator; }
/** * Set a Binary Data to this request using a singleton temp file creator * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data) { final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
static <A, B> Accumulator<ByteString, F.Either<Result, A>> delegate(play.api.mvc.BodyParser<B> delegate, Function<B, A> transform, Http.RequestHeader request) { Accumulator<ByteString, scala.util.Either<play.api.mvc.Result, B>> javaAccumulator = delegate.apply(request.asScala()).asJava(); return javaAccumulator.map(result -> { if (result.isLeft()) { return F.Either.Left(result.left().get().asJava()); } else { return F.Either.Right(transform.apply(result.right().get())); } }, JavaParsers.trampoline()); } }
/** * Set a Binary Data to this request using a singleton temp file creator * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data) { final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
static <A, B> Accumulator<ByteString, F.Either<Result, A>> delegate(play.api.mvc.BodyParser<B> delegate, Function<B, A> transform, Http.RequestHeader request) { Accumulator<ByteString, scala.util.Either<play.api.mvc.Result, B>> javaAccumulator = delegate.apply(request.asScala()).asJava(); return javaAccumulator.map(result -> { if (result.isLeft()) { return F.Either.Left(result.left().get().asJava()); } else { return F.Either.Right(transform.apply(result.right().get())); } }, JavaParsers.trampoline()); } }
/** * Set a Binary Data to this request using a singleton temp file creator * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(ByteString data) { final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream"); }
static <A, B> Accumulator<ByteString, F.Either<Result, A>> delegate(play.api.mvc.BodyParser<B> delegate, Function<B, A> transform, Http.RequestHeader request) { Accumulator<ByteString, scala.util.Either<play.api.mvc.Result, B>> javaAccumulator = delegate.apply(request.asScala()).asJava(); return javaAccumulator.map(result -> { if (result.isLeft()) { return F.Either.Left(result.left().get().asJava()); } else { return F.Either.Right(transform.apply(result.right().get())); } }, JavaParsers.trampoline()); } }
/** * Set a Multipart Form url encoded body to this request saving it as a raw body. * * @param data the multipart-form parameters * @param temporaryFileCreator the temporary file creator. * @param mat a Akka Streams Materializer * @return the modified builder */ public RequestBuilder bodyRaw(List<MultipartFormData.Part<Source<ByteString, ?>>> data, Files.TemporaryFileCreator temporaryFileCreator, Materializer mat) { String boundary = MultipartFormatter.randomBoundary(); try { ByteString materializedData = MultipartFormatter .transform(Source.from(data), boundary) .runWith(Sink.reduce(ByteString::concat), mat) .toCompletableFuture() .get(); play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(materializedData.size(), temporaryFileCreator.asScala(), materializedData); return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), MultipartFormatter.boundaryToContentType(boundary)); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Failure while materializing Multipart/Form Data", e); } }