From ea47c72552b6500c5bdb058031dde38dfacd1604 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 27 Sep 2019 15:10:44 +0200 Subject: [PATCH] Added an option to bufferontent for WireMockRestServiceServer fixes gh-860 --- .../wiremock/WireMockRestServiceServer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockRestServiceServer.java b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockRestServiceServer.java index 61837aff5b..f1ca789a59 100644 --- a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockRestServiceServer.java +++ b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockRestServiceServer.java @@ -83,6 +83,8 @@ public final class WireMockRestServiceServer { private String baseUrl = ""; + private boolean bufferContent = false; + private MockRestServiceServerBuilder builder; private List locations = new ArrayList(); @@ -116,6 +118,15 @@ public final class WireMockRestServiceServer { return this; } + /** + * Flag to tell the server to buffer the contents of the response. + * @return this + */ + public WireMockRestServiceServer bufferContent() { + this.bufferContent = true; + return this; + } + /** * If stub locations are given as a directory, then we search recursively in that * directory for files with this suffix. Default is ".json". @@ -180,6 +191,9 @@ public final class WireMockRestServiceServer { if (this.ignoreExpectOrder) { this.builder.ignoreExpectOrder(true); // default is false } + if (this.bufferContent) { + this.builder.bufferContent(); + } MockRestServiceServer server = this.builder.build(); List mappings = new ArrayList<>(); for (String location : this.locations) {