Apache JMeter 的 Cookie 管理器不会将 cookie 添加到 POST 请求 [英] Cookie Manager of Apache JMeter doesn't add the cookie to POST request

查看:30
本文介绍了Apache JMeter 的 Cookie 管理器不会将 cookie 添加到 POST 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制定了非常简单的测试计划.

I build up very simple test plan.

  1. 登录:POST,返回会话cookie.
  2. 获取状态:GET,返回一个用户状态.
  3. 创建资源:POST,为资源提供JSON正文.

所以我的测试计划"看起来像:

So my 'Test Plan' looks like:

  • 测试计划
    • 线程组
      • HTTP 请求默认值
      • HTTP Cookie 管理器
      • 登录(HTTP 请求采样器:POST)
      • 获取状态(HTTP 请求采样器:GET)
      • 创建资源(HTTP 请求采样器:POST)

      'Login'生成的cookie被正确添加到'Get State'中.
      但是创建资源"没有 cookie.我改变了他们的顺序,但它没有帮助.我首先使用了默认选项并更改了一些选项,但它也无济于事.

      The cookie generated by 'Login' is added to 'Get State' correctly.
      But 'Create Resource' has NO cookie. I changed their order but it doesn't help. I used the default options firstly and changed some options but it also doesn't help.

      是JMeter的bug吗?或者只是 POST http 请求不能有 cookie?
      请给我任何建议.

      Is it a bug of JMeter? or just POST http request is not able to have cookie?
      Please give me any advice.

      [已解决]
      我注意到它与路径有关,而不是方法.
      您想查看 cookie 的域以及路径.我的意思是,可以在服务器端通过 Set-Cookie 头定义 cookie 的路径和域.

      [SOLVED]
      I noticed that it is related to the path, not the method.
      You'd like to look at the domain of the cookie as well as the path. I mean, the path and the domain of a cookie could be defined in the server side through Set-Cookie header.

      推荐答案

      另一个解决方案是在 jmeter.properties 中设置 CookieManager.check.cookies=false 通常位于 bin 中的 jmeter 启动脚本旁边.

      Another solution is to set CookieManager.check.cookies=false in jmeter.properties usually sitting besides the jmeter startup script in bin.

      由于某些原因,JMeter 认为如果您在 http:/somesite/somethingelse 上,则无法在 cookie 中设置 path=/something.那就是路径必须与您当前所在的路径相匹配.

      JMeter for some reasons thinks that you can't set the path=/something in a cookie if you are on http:/somesite/somethingelse. That is the path has to match the path your currently on.

      如果确实存在,我从未见过浏览器强制执行此限制.我已经看到并编写了几个使用这种技术来设置安全 cookie 然后将某人说的转发给/admin 的站点.

      I've never seen a browser enforce this limitation if it actually exists. I've seen and written several sites that use this technique to set a secure cookie and then forward someone say to /admin.

      我希望这个选项至少在 GUI 中,这样我就不必更改属性文件.我认为 BlazeMeter 足够聪明,可以关闭检查 flood.io 不存在的位置.如果由我决定,我会完全删除检查此内容的代码.为什么要让负载测试器变得更难呢.

      I wish this option was at least in the GUI so I didn't have to change the properties file. I think BlazeMeter is smart enough to turn off checking where flood.io is not. If it were up to me I'd just remove the code that checks this entirely. Why make the load tester any harder then it needs to be.

      这篇关于Apache JMeter 的 Cookie 管理器不会将 cookie 添加到 POST 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆