Hello folks! I am trying to use wiremock for recor...
# wiremock-java
s
Hello folks! I am trying to use wiremock for record and playback for integration tests which involves aws s3. I am able to get the record and playback working following the documentation upto most of the extent, except that wiremock is filtering out
Content-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
Copy code
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 ?
A snippet for wiremock startRecorer
Copy code
wireMockServer.startRecording(recordSpec().forTarget(S3_ENDPOINT)
                .extractBinaryBodiesOver(204800).captureHeader("Content-Length", true).transformers("content-length-transformer"));
t
Content-Length
is excluded because it’s calculated automatically on the response (assuming you have configured for this vs. chunked responses).