服务器报错日志如下:
Caused by: feign.codec.DecodeException: Error while extracting response for type [class com.sunyard.sany.ccb.resp.BusinessStatusResp] and content type [application/json;charset=utf-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
通过比对发现,wiremock会自动在heard头添加如下参数
'Matched-Stub-Id': 'da9ac487-02e8-4ef1-ba4b-9bfe01c68504', 'Vary': 'Accept-Encoding, User-Agent', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked'
引起报错的正是: 'Content-Encoding': 'gzip'
服务器不改代码,能正确解析的写法
{
"request":{
"urlPattern":"/test/status.*",
"bodyPatterns":[{"matchesJsonPath":"$[?(@.test== 'ttttt')]"}]
},
"response":{
"status":200,
"jsonBody" : {
"code": "0",
"message": "成功",
"status": "2"
},
"headers" : {
"Content-Type" : "application/json;charset=utf-8",
"Content-Encoding":""
}
}
}
解决过程中,看到的其他解决办法(未验证)