3535import java .util .TreeSet ;
3636
3737import static io .qameta .allure .attachment .http .HttpRequestAttachment .Builder .create ;
38- import static io .qameta .allure .attachment .http .HttpResponseAttachment .Builder .create ;
3938import static java .util .Optional .ofNullable ;
4039
4140/**
@@ -45,11 +44,20 @@ public class AllureRestAssured implements OrderedFilter {
4544
4645 private static final String HIDDEN_PLACEHOLDER = "[ BLACKLISTED ]" ;
4746
47+ private int maxAllowedPrettifyLength = 1048576 ;
48+
4849 private String requestTemplatePath = "http-request.ftl" ;
4950 private String responseTemplatePath = "http-response.ftl" ;
5051 private String requestAttachmentName = "Request" ;
5152 private String responseAttachmentName ;
5253
54+ public AllureRestAssured () {
55+ }
56+
57+ public AllureRestAssured (int maxAllowedPrettifyLength ) {
58+ this .maxAllowedPrettifyLength = maxAllowedPrettifyLength ;
59+ }
60+
5361 public AllureRestAssured setRequestTemplate (final String templatePath ) {
5462 this .requestTemplatePath = templatePath ;
5563 return this ;
@@ -123,10 +131,13 @@ public Response filter(final FilterableRequestSpecification requestSpec,
123131 final String attachmentName = ofNullable (responseAttachmentName )
124132 .orElse (response .getStatusLine ());
125133
126- final HttpResponseAttachment responseAttachment = create (attachmentName )
134+ final String responseAsString = response .getBody ().asString ();
135+ final String body = responseAsString .length () > maxAllowedPrettifyLength ? responseAsString : prettifier .getPrettifiedBodyIfPossible (response , response .getBody ());
136+
137+ final HttpResponseAttachment responseAttachment = HttpResponseAttachment .Builder .create (attachmentName )
127138 .setResponseCode (response .getStatusCode ())
128139 .setHeaders (toMapConverter (response .getHeaders (), hiddenHeaders ))
129- .setBody (prettifier . getPrettifiedBodyIfPossible ( response , response . getBody ()) )
140+ .setBody (body )
130141 .build ();
131142
132143 new DefaultAttachmentProcessor ().addAttachment (
0 commit comments