I am testing with Wiremock and Apache Camel, while status code is different(2xx and 404), even Wiremock is configured to return nothing (no withBody()
stubbing), the body I get from
exchange.getIn().getBody(String.class)
and
exchange.getProperties().get(HTTP_RESPONSE_TEXT)
are different.
I have this log lines:
logger.debugf("Status code for endpoint %d: %d, response body: %s, response text(Camel header): %s", endpointId, statusCode, exchange.getIn().getBody(String.class), properties.get(HTTP_RESPONSE_TEXT));
And, when it's 2xx:
Status code for endpoint 0: 200, response body: , response text(Camel header): null
When it's 404:
Status code for endpoint 1: 404, response body: null, response text(Camel header): null
So, properties.get(HTTP_RESPONSE_TEXT)
seems always consistent(always null).
Why the difference? So I always use properties.get(HTTP_RESPONSE_TEXT)
right?
Wiremock stubbing is like:
server.stubFor(post(urlPathMatching("/operator/.*/endpoint/[0-9]*"))
.withRequestBody(allFieldsPattern())
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
));
server.stubFor(delete(urlPathMatching("/operator/.*/endpoint/[0-9]*"))
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
));
When I use java 11 HttpClient
, it's always empty string. So I don't know which is standard.
Wiremock 2.33.2
, jre8-standalone
.