如何解决Wiremock 返回编码错误的响应
我在 windows 上使用 spring-cloud-contract wiremock 来模拟一些 rest api 端点,如下所示:
def "returns status 200 for accounts route"() {
when:
stubFor(
get(urlPathMatching("/v1/user/isEligible.*"))
.willReturn(
aResponse()
.withHeader("content-type","application/json;charset=UTF-8")
.withBody("{}")
))
日志显示如下:
Matched response deFinition:
{
"status" : 200,"body" : "{}","headers" : {
"content-type" : "application/json;charset=UTF-8"
}
}
Response:
HTTP/1.1 200
content-type: [application/json;charset=UTF-8]
Matched-Stub-Id: [4ddd684b-aa47-4afc-b9da-0eded7e81bef]
2021-02-05 12:46:30,942 ERROR [correlation] [XNIO-1 task-1] o.a.c.u.CamelLogger :156 - Current error body : �� C���
2021-02-05 12:46:30,948 ERROR [correlation] [XNIO-1 task-1] o.a.c.u.CamelLogger :156 - Exchange[ExchangePattern: InOut,Properties: {Authorization=allow,CamelCharsetName=utf-8,CamelCreatedTimestamp=Fri Feb 05 12:46:29 CET 2021,CamelExceptionCaught=com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR,code 31)): only regular white space (\r,\n,\t) is allowed between tokens
有谁知道为什么响应正文被编码为:�� C���
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。