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

查看:1737
本文介绍了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 Manager

      • 登录(HTTP请求采样器:POST)

      • 获取状态(HTTP请求采样器:GET)

      • (HTTP Request Sampler:POST)

      • Test Plan
        • Thread Group
          • HTTP Request Defaults
          • HTTP Cookie Manager
          • Login (HTTP Request Sampler: POST)
          • Get State (HTTP Request Sampler: GET)
          • Create Resource (HTTP Request Sampler: POST)

          登录生成的Cookie会正确添加到获取状态。

          但创建资源没有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的错误吗?或者只是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的域以及路径。
          我的意思是,cookie的路径和域可以在服务器端通过Set-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因为某些原因认为你不能在cookie中设置path = / something,如果你在http:/ somesite / somethingelse。这是路径必须匹配您当前的路径。

          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,然后转发别人说/管理员。

          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天全站免登陆