空手道模拟

发布于 2025-02-01 15:02:09 字数 613 浏览 3 评论 0原文

我想创建一个与空手道的模拟,以对进行if-none-Match标题。我试图做显示的事情在这里

Scenario: pathMatches('/path') && methodIs('get') && karate.get('requestHeaders.If-None-Match[0]') == '1'
   * def responseStatus = 304
   * def responseHeaders = { 'ETag': '1' }

。它忽略了空手道。get零件,使用后定义的方案(没有标头的相同的方案):

Scenario: pathMatches('/path') && methodIs('get')
...

我在这里做错了什么?

I want to create a mock with karate to act on If-None-Match header. I tried to do what is shown here

Scenario: pathMatches('/path') && methodIs('get') && karate.get('requestHeaders.If-None-Match[0]') == '1'
   * def responseStatus = 304
   * def responseHeaders = { 'ETag': '1' }

It is not working. It is ignoring the karate.get part, and using the scenario defined after (the same one without headers):

Scenario: pathMatches('/path') && methodIs('get')
...

What am I doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2025-02-08 15:02:09

这样做。我能够获得响应匹配。

Scenario: pathMatches('/path') && methodIs('get') && headerContains('If-None-Match', '1')
* def responseStatus = 200
* def responseHeaders = {'Etag':'1' }

Do it like this. I was able to get a response match.

Scenario: pathMatches('/path') && methodIs('get') && headerContains('If-None-Match', '1')
* def responseStatus = 200
* def responseHeaders = {'Etag':'1' }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文