Wiremock 管理存根问题

Wiremock admin stub issue

我有一个存根文件,我正在通过 c# admin api 发送到一个独立的 wiremock 实例。当我通过邮递员发送时,我得到了预期的回复,除了回复 body 总是空的,即使在我的文件中我有这个:

"Response": {
"Delay": 500,
"UseTransformer": true,
"StatusCode": 205,
"BodyAsJson": { "result": "PRIO = 1 . test" },
"Headers": {
  "Content-Type": "application/json",
  "a": "b"
}

}

我看到预期的 header a b 但 body 中什么也没有。另外,如果我将其更改为纯文本:

"Response": {
"Delay": 500,
"UseTransformer": true,
"StatusCode": 205,
"body": "Hello world!",
"Headers": {
  "Content-Type": "application/text",
  "a": "b"
}

这也不起作用 - 我做错了什么?

很难说查看您提供的数据,您到底向独立的 Wiremock 发送了什么请求。

调查此问题的方法是点击 Wiremock /__admin/mappings 中的 get all mappings endpoint 并检查您发送的响应是否是 Wiremock 中准备好的。

难道HTTP205不允许你return一个body?那么你可以试试 HTTP 200 ?

另见 https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

10.2.6 205 Reset Content

The server has fulfilled the request and the user agent SHOULD reset the document view which caused the request to be sent. This response is primarily intended to allow input for actions to take place via user input, followed by a clearing of the form in which the input is given so that the user can easily initiate another input action. The response MUST NOT include an entity.