Sandeep Vinayak
07/03/2024, 7:06 PMContent-Length
in my recorded response. I wrote my custom response builder and included the Content-Length
but wiremock still filters it out. Here is my customer builder snippet
Response.Builder()
.status(response.getStatus())
.headers(response.getHeaders())
.body(response.getBody())
.headers(response.getHeaders().plus(new HttpHeader("X-Content-Length", String.valueOf(response.getBody().length))).plus(new HttpHeader("Content-Length", String.valueOf(response.getBody().length))).plus(new HttpHeader("ContentLength", String.valueOf(response.getBody().length))))
.build();
I can see that X-Content-Length
and ContentLength
do get recorded but not the Content-Length
I tried to get into the the codebase, and it seems like we are excluding this header. Is there any workaround to get the Content-Length
in the recorded response ?Sandeep Vinayak
07/03/2024, 7:09 PMwireMockServer.startRecording(recordSpec().forTarget(S3_ENDPOINT)
.extractBinaryBodiesOver(204800).captureHeader("Content-Length", true).transformers("content-length-transformer"));
Tom
07/04/2024, 2:24 PMContent-Length
is excluded because it’s calculated automatically on the response (assuming you have configured for this vs. chunked responses).