提问人:Ahmed Tawfik 提问时间:11/18/2023 更新时间:11/18/2023 访问量:17
WireMock 客户端在来自服务器的 HTTP 308 永久重定向响应上抛出 JsonException
WireMock client throws JsonException on HTTP 308 permanent redirect response from server
问:
我在调试器中运行以下两个命令:
mockServerClient.register(put(urlEqualTo("apiEndpoint")).willReturn(ok()));
mockServerClient.getStubMapping(UUID.fromString("d8fb42c5-927d-476b-bbb3-20f92a31bd05"/*
UUID copied from register response */));
线模拟客户端的构建:
var mockServerClient = new WireMock("mock-server.ourInternalDomain.com", 80);
调用返回一个完整的对象(从调试器复制,是的,上面的不同 UUID 作为不同的调用实例):register
{
"id" : "50434254-76db-45c6-8601-60399544833b",
"request" : {
"url" : "apiEndpoint",
"method" : "PUT"
},
"response" : {
"status" : 200
},
"uuid" : "50434254-76db-45c6-8601-60399544833b"
}
但以下调用返回 308 永久重定向响应:getStubMapping
{
"errors" : [ {
"code" : 10,
"source" : { },
"title" : "Error parsing JSON",
"detail" : "Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"<html>\r\n<head><title>308 Permanent Redirect</title></head>\r\n<body>\r\n<center><h1>308 Permanent Redirect</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n\"; line: 1, column: 2]"
} ]
}
通过 Postman 调用模拟服务器会产生有效结果,因此无法重现该问题。
为什么我得到有效的响应,却没有得到有效的响应?register
getStubMapping
Java17, 黄瓜
答: 暂无答案
评论
mockServerClient = new WireMock("https", baseUrl, 443);