`
desert3
  • 浏览: 2140121 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

JMeter Http Cookie Manager

 
阅读更多
JMeter Http Cookie Manager的作用:
0,自动管理
1,象浏览器一样的存储和发送Cookie。如果你请求一个站点,然后他的Response中包含Cookie,Cookie Manager就会自动地保存这些Cookie并在所有后来发送到该站点的请求中使用这些Cookie的值。(在View Results Tree的Request界面可以看到被发送的Cookie Data, 同时每个线程的Cookie Manager是相互独立的)

接受到的Cookie的值能被存储到JMeter 线程变量中(2.3.2版本后的JMeter不自动做这个事情)。要把Cookies保存到线程变量中,要定义属性"CookieManager.save.cookies=true"。
线程变量名为COOKIE_ + Cookie名。属性CookieManager.name.prefix= 可以用来修改默认的COOKIE_的值。
2,手动添加Cookie到Cookie Manager,需求注意的是这些Cookie的值被会所有线程共享

定义:属性"CookieManager.save.cookies=true"
在jmeter.properties文件中增加CookieManager.save.cookies=true,然后在Debug Sampler中就能看到COOKIE_xxx这样的变量,或者也可以使用正则表达式来提取Cookie的值,参考:JMeter正则表达式提取器

JMeter Http Cookie Manager的属性:
Clear Cookies each Iteration    If selected, all server-defined cookies are cleared each time the main Thread Group loop is executed. In JMeter versions after 2.3, any cookies defined in the GUI are not cleared. Yes
Cookie Policy The cookie policy that will be used to manage the cookies. "compatibility" is the default, and should work in most cases. See http://hc.apache.org/httpclient-3.x/cookies.html and http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/cookie/CookiePolicy.html [Note: "ignoreCookies" is equivalent to omitting the CookieManager.] Yes
User-Defined Cookies This gives you the opportunity to use hardcoded cookies that will be used by all threads during the test execution.
The "domain" is the hostname of the server (without http://); the port is currently ignored. No (discouraged, unless you know what you're doing)
    以下Cookies标准,HttpClient3.1可以支持。
    RFC2109
    RFC2109是W3C组织第一次推出的官方Cookies标准。理论上,所有使用版本1Cookies的服务端都应该使用此标准。HttpClient已经将此标准设定为默认。
    遗憾的是,许多服务端不正确的实现了标准或者仍然使用Netscape标准。所有有时感到此标准太多于严格。
    RFC2109是HttpClient使用的默认Cookies协议。

    RFC2965
    RFC2965定义了版本2并且尝试去弥补在版本1中Cookie的RFC2109标准的缺点。RFC2965是,并规定RFC2965最终取代RFC2109.
    发送RFC2965标准Cookies的服务端,将会使用Set-Cookie2 header添加到Set-Cookie Header信心中,RFC2965 Cookies是区分端口的。

    Netscape标准
    Netscape是最原始的Cookies规范,同时也是RFC2109的基础。尽管如此,还是在很多重要的方面与RFC2109不同,可能需要特定服务器才可以兼容。

    Browser Compatibility
    这种兼容性设计要求是适应尽可能多的不同的服务器,尽管不是完全按照标准来实现的。如果你遇到了解析Cookies的问题,你就可能要用到这一个规范。
    有太多的web站点是用CGI脚本去实现的,而导致只有将所有的Cookies都放入Request header才可以正常的工作。这种情况下最好设置http.protocol.single-cookie-header参数为true。

    Ignore Cookies
    此规格忽略所有Cookie 。被用来防止HttpClient接受和发送的Cookie。

http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics