linebreak on payloads for elastic _bulk endpoint

This commit is contained in:
phact 2023-08-29 22:05:01 -04:00
parent e4903c37b9
commit 68b7f758f5

View File

@ -46,9 +46,10 @@ public class HttpOpDispenser extends BaseOpDispenser<HttpOp, HttpSpace> {
LongFunction<HttpRequest.Builder> builderF = l -> HttpRequest.newBuilder();
LongFunction<String> bodyF = op.getAsFunctionOr("body", null);
LongFunction<HttpRequest.BodyPublisher> bodyPublisherF =
l -> Optional.ofNullable(bodyF.apply(l)).map(HttpRequest.BodyPublishers::ofString).orElse(
HttpRequest.BodyPublishers.noBody()
);
l -> Optional.ofNullable(bodyF.apply(l))
.map(s -> s + "\n") // the elastic _bulk endpoint requires a newline at the end of the body
.map(HttpRequest.BodyPublishers::ofString)
.orElse(HttpRequest.BodyPublishers.noBody());
LongFunction<String> methodF = op.getAsFunctionOr("method", "GET");
LongFunction<HttpRequest.Builder> initBuilderF =